mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
98 lines
5.6 KiB
Plaintext
98 lines
5.6 KiB
Plaintext
@model FeaturesViewModel
|
|
@using Orchard.Localization;
|
|
@using Orchard.Modules.Extensions;
|
|
@using Orchard.Modules.ViewModels;
|
|
@using Orchard.Utility.Extensions;
|
|
@using Orchard.Modules.Models;
|
|
@{
|
|
Style.Require("ModulesAdmin");
|
|
Style.Require("Switchable");
|
|
Script.Require("Switchable");
|
|
|
|
WorkContext.Layout.BeforeContent.Add(New.BeforeContent(Title: "Modules"), "5");
|
|
}
|
|
|
|
@if (Model.Features.Count() > 0) {
|
|
<ul class="features summary-view switchable">@{
|
|
var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category, new DoghouseComparer("Core")).GroupBy(f => f.Descriptor.Category);
|
|
foreach (var featureGroup in featureGroups) {
|
|
var categoryName = LocalizedString.TextOrDefault(featureGroup.First().Descriptor.Category, T("Uncategorized"));
|
|
var categoryClassName = string.Format("category {0}", Html.Encode(categoryName.ToString().HtmlClassify()));
|
|
if (featureGroup == featureGroups.First()) {
|
|
categoryClassName += " first";
|
|
}
|
|
if (featureGroup == featureGroups.Last()) {
|
|
categoryClassName += " last";
|
|
}
|
|
|
|
//temporarily "disable" actions on core features
|
|
bool showActions;
|
|
<li class="@categoryClassName">
|
|
<h2>@categoryName</h2>
|
|
<ul>@{
|
|
var features = featureGroup.OrderBy(f => f.Descriptor.Name);
|
|
foreach (var feature in features) {
|
|
//hmmm...I feel like I've done this before...
|
|
var featureId = feature.Descriptor.Id.AsFeatureId(n => T(n));
|
|
var featureName = string.IsNullOrEmpty(feature.Descriptor.Name) ? feature.Descriptor.Id : feature.Descriptor.Name;
|
|
var featureState = feature.IsEnabled ? "enabled" : "disabled";
|
|
var featureClassName = string.Format("feature {0}", featureState + (feature.NeedsUpdate ? " update" : String.Empty));
|
|
if (feature == features.First()) {
|
|
featureClassName += " first";
|
|
}
|
|
if (feature == features.Last()) {
|
|
featureClassName += " last";
|
|
}
|
|
var dependencies = (from d in feature.Descriptor.Dependencies
|
|
select (from f in Model.Features where f.Descriptor.Id == d select f).SingleOrDefault()).Where(f => f != null).OrderBy(f => f.Descriptor.Name);
|
|
var missingDependencies = feature.Descriptor.Dependencies
|
|
.Where(d => !Model.Features.Any(f => f.Descriptor.Id == d));
|
|
showActions = categoryName.ToString() != "Core" && missingDependencies.Count() == 0;
|
|
<li class="@featureClassName" id="@featureId" title="@T("{0} is {1}", Html.AttributeEncode(featureName), featureState)">
|
|
<div class="summary">
|
|
<div class="properties">
|
|
<h3>@featureName</h3>
|
|
<p class="description">@feature.Descriptor.Description</p>@if (feature.Descriptor.Dependencies != null && feature.Descriptor.Dependencies.Any()) {
|
|
<div class="dependencies">
|
|
<h4>@T("Depends on:")</h4>
|
|
@Html.UnorderedList(dependencies,
|
|
(s, i) => Html.Link(string.IsNullOrEmpty(s.Descriptor.Name) ? s.Descriptor.Id : s.Descriptor.Name, string.Format("#{0}", s.Descriptor.Id.AsFeatureId(n => T(n)))),
|
|
"",
|
|
"dependency",
|
|
"")
|
|
</div>}
|
|
@if (missingDependencies.Any()) {
|
|
<div class="missingdependencies">
|
|
<h4>@T("Missing:")</h4>
|
|
@Html.UnorderedList(missingDependencies, (s, i) => MvcHtmlString.Create(s), "", "missingdependency", "")
|
|
</div>}
|
|
</div>
|
|
<div class="actions">
|
|
@if (showActions) {
|
|
if (feature.IsEnabled) {
|
|
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Disable", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) {
|
|
@Html.Hidden("id", feature.Descriptor.Id, new {id = ""})
|
|
@Html.Hidden("force", true)
|
|
<button type="submit">@T("Disable")</button>
|
|
}
|
|
}
|
|
else {
|
|
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Enable", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) {
|
|
@Html.Hidden("id", feature.Descriptor.Id, new { id = "" })
|
|
@Html.Hidden("force", true)
|
|
<button type="submit">@T("Enable")</button>
|
|
}
|
|
}
|
|
}
|
|
@if(feature.NeedsUpdate){
|
|
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Update", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) {
|
|
@Html.Hidden("id", feature.Descriptor.Id, new { id = "" })
|
|
<button type="submit" class="update">@T("Update")</button>
|
|
}
|
|
}
|
|
</div>
|
|
</div>
|
|
</li>}
|
|
}</ul>
|
|
</li>}
|
|
}</ul>} |