mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +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;
|
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) {
|
public virtual ContentItem Get(int id) {
|
||||||
// obtain root record to determine the model type
|
// obtain root record to determine the model type
|
||||||
var record = _contentItemRepository.Get(id);
|
var record = _contentItemRepository.Get(id);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Orchard.Models {
|
|||||||
void Create(ContentItem contentItem);
|
void Create(ContentItem contentItem);
|
||||||
|
|
||||||
ContentItem Get(int id);
|
ContentItem Get(int id);
|
||||||
|
IEnumerable<ContentItem> Get(IEnumerable<int> id);
|
||||||
|
|
||||||
IEnumerable<ModelTemplate> GetDisplays(IContent contentItem);
|
IEnumerable<ModelTemplate> GetDisplays(IContent contentItem);
|
||||||
IEnumerable<ModelTemplate> GetEditors(IContent contentItem);
|
IEnumerable<ModelTemplate> GetEditors(IContent contentItem);
|
||||||
|
|||||||
@@ -5,24 +5,8 @@ using Orchard.Models;
|
|||||||
|
|
||||||
namespace Orchard.Mvc.Html {
|
namespace Orchard.Mvc.Html {
|
||||||
public static class ContentItemExtensions {
|
public static class ContentItemExtensions {
|
||||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, string linkText, IContent item) {
|
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, string linkText, IContent content) {
|
||||||
return ItemDisplayLink(html, linkText, item.ContentItem);
|
var display = content.As<IContentDisplayInfo>();
|
||||||
}
|
|
||||||
|
|
||||||
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>();
|
|
||||||
if (display == null)
|
if (display == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -30,12 +14,12 @@ namespace Orchard.Mvc.Html {
|
|||||||
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, ContentItem item) {
|
public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, IContent content) {
|
||||||
return ItemDisplayLink(html, null, item);
|
return ItemDisplayLink(html, null, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, string linkText, ContentItem item) {
|
public static MvcHtmlString ItemEditLink(this HtmlHelper html, string linkText, IContent content) {
|
||||||
var display = item.As<IContentDisplayInfo>();
|
var display = content.As<IContentDisplayInfo>();
|
||||||
if (display == null)
|
if (display == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -43,8 +27,8 @@ namespace Orchard.Mvc.Html {
|
|||||||
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
return html.ActionLink(linkText ?? display.DisplayText, Convert.ToString(values["action"]), values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MvcHtmlString ItemEditLink(this HtmlHelper html, ContentItem item) {
|
public static MvcHtmlString ItemEditLink(this HtmlHelper html, IContent content) {
|
||||||
return ItemEditLink(html, null, item);
|
return ItemEditLink(html, null, content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user