2010-04-28 11:47:29 -07:00
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<FeaturesViewModel>" %>
2010-06-12 13:33:35 -07:00
<%@ Import Namespace="Orchard.Localization" %>
2010-05-19 14:09:13 -07:00
<%@ Import Namespace="Orchard.Modules.Extensions" %>
2010-04-27 11:24:06 -07:00
<%@ Import Namespace="Orchard.Modules.ViewModels"%>
2010-05-17 16:25:21 -07:00
<%@ Import Namespace="Orchard.Utility.Extensions" %><%
2010-07-20 23:34:09 -07:00
Html.RegisterStyle("admin.css"); %>
2010-06-08 23:42:20 -07:00
<h1><%: Html.TitleForPage(T("Manage Features").ToString()) %></h1>
2010-05-14 15:52:22 -07:00
<% if (Model.Features.Count() > 0) { %>
2010-07-20 23:34:09 -07:00
<ul class="<% Html.RenderPartial("UI/Switchable", "features summary-view"); %>"><%
2010-05-14 15:52:22 -07:00
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category).GroupBy(f => f.Descriptor.Category);
2010-05-17 14:38:26 -07:00
foreach (var featureGroup in featureGroups) {
2010-06-12 13:33:35 -07:00
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
2010-05-17 14:38:26 -07:00
var categoryClassName = string.Format("category {0}", Html.Encode(categoryName.ToString().HtmlClassify()));
if (featureGroup == featureGroups.First())
categoryClassName += " first";
if (featureGroup == featureGroups.Last())
2010-05-19 10:02:47 -07:00
categoryClassName += " last";
//temporarily "disable" actions on core features
var showActions = categoryName.ToString() != "Core"; %>
2010-05-17 14:38:26 -07:00
<li class="<%=categoryClassName %>">
2010-06-08 22:44:30 -07:00
<h2><%: categoryName %></h2>
2010-05-14 15:52:22 -07:00
<ul><%
var features = featureGroup.OrderBy(f => f.Descriptor.Name);
2010-05-17 14:38:26 -07:00
foreach (var feature in features) {
//hmmm...I feel like I've done this before...
2010-05-19 14:09:13 -07:00
var featureId = feature.Descriptor.Name.AsFeatureId(n => T(n));
2010-05-18 00:04:41 -07:00
var featureState = feature.IsEnabled ? "enabled" : "disabled";
2010-07-06 12:51:26 -07:00
var featureClassName = string.Format("feature {0}", featureState + (Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name) ? " update" : String.Empty));
2010-05-17 14:38:26 -07:00
if (feature == features.First())
featureClassName += " first";
if (feature == features.Last())
featureClassName += " last"; %>
2010-06-10 23:39:49 -07:00
<li class="<%: featureClassName %>" id="<%: featureId %>" title="<%: T("{0} is {1}", Html.AttributeEncode(feature.Descriptor.Name), featureState) %>">
2010-05-14 15:52:22 -07:00
<div class="summary">
<div class="properties">
2010-05-28 15:17:33 -07:00
<h3><%:feature.Descriptor.Name %></h3>
<p class="description"><%:feature.Descriptor.Description %></p><%
2010-07-09 14:14:17 -07:00
if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) { %>
2010-05-17 14:38:26 -07:00
<div class="dependencies">
2010-06-08 23:42:20 -07:00
<h4><%: T("Depends on:")%></h4>
2010-06-10 00:07:26 -07:00
<%: Html.UnorderedList(
2010-05-17 14:38:26 -07:00
feature.Descriptor.Dependencies.OrderBy(s => s),
2010-06-18 13:44:02 -07:00
(s, i) => Html.Link(s, string.Format("#{0}", s.AsFeatureId(n => T(n)))),
2010-05-17 14:38:26 -07:00
"",
"dependency",
"") %>
</div><%
} %>
2010-05-19 10:02:47 -07:00
</div><%
if (showActions) { %>
2010-05-17 14:38:26 -07:00
<div class="actions"><%
2010-05-19 00:00:56 -07:00
if (feature.IsEnabled) {
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Disable", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %>
2010-06-08 23:42:20 -07:00
<%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%>
<%: Html.Hidden("force", true)%>
<button type="submit"><%: T("Disable") %></button><%
2010-05-19 00:00:56 -07:00
}
} else {
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Enable", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %>
2010-06-08 23:42:20 -07:00
<%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%>
<%: Html.Hidden("force", true)%>
<button type="submit"><%: T("Enable") %></button><%
2010-05-19 00:00:56 -07:00
}
2010-07-06 12:51:26 -07:00
}
if(Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name)){
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Update", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %>
<%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%>
<%: Html.Hidden("force", true)%>
<button type="submit" class="update"><%: T("Update") %></button><%
}
}
%>
2010-05-19 10:02:47 -07:00
</div><%
} %>
2010-05-14 15:52:22 -07:00
</div>
2010-04-27 11:24:06 -07:00
</li><%
} %>
2010-05-14 15:52:22 -07:00
</ul>
</li><%
} %>
</ul><%
2010-04-28 11:47:29 -07:00
} %>