--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-10-14 21:12:45 -07:00
22 changed files with 161 additions and 197 deletions

View File

@@ -207,29 +207,10 @@ namespace Orchard.Tests.Modules.Themes.Services {
}
}
public IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor) {
var extensions = new[] {
new ExtensionDescriptor {Name = "ThemeOne", ExtensionType = "Theme"},
new ExtensionDescriptor {Name = "ThemeTwo", BaseTheme = "ThemeOne", ExtensionType = "Theme"},
new ExtensionDescriptor {Name = "ThemeThree", BaseTheme = "TheThemeThatIsntThere", ExtensionType = "Theme"},
new ExtensionDescriptor {Name = "ThemeFourBasedOnFive", BaseTheme = "ThemeFiveBasedOnFour", ExtensionType = "Theme"},
new ExtensionDescriptor {Name = "ThemeFiveBasedOnFour", BaseTheme = "ThemeFourBasedOnFive", ExtensionType = "Theme"},
};
foreach (var extension in extensions) {
extension.Features = new[] { new FeatureDescriptor { Extension = extension, Name = extension.Name } };
yield return extension;
}
}
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
return AvailableExtensions().SelectMany(ed => ed.Features);
}
public IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor) {
return AvailableExtensions().SelectMany(ed => ed.Features);
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
return featureDescriptors.Select(FrameworkFeature);
}

View File

@@ -87,18 +87,10 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
throw new NotSupportedException();
}
public IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
return _availableFeautures;
}
public IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
throw new NotSupportedException();
}

View File

@@ -90,19 +90,11 @@ namespace Orchard.Tests.Environment {
yield return ext;
}
public IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
// note - doesn't order properly
return AvailableExtensions().SelectMany(ed => ed.Features);
}
public IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
foreach (var descriptor in featureDescriptors) {
if (descriptor.Name == "Orchard.Framework") {

View File

@@ -11,18 +11,10 @@ namespace Orchard.Tests.Stubs {
throw new NotSupportedException();
}
public IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
throw new NotSupportedException();
}
public IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor) {
throw new NotSupportedException();
}
public IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors) {
throw new NotSupportedException();
}

View File

@@ -198,7 +198,7 @@ namespace Orchard.Core.Contents.Controllers {
ActionResult CreatableTypeList() {
var list = Shape.List();
list.AddRange(GetCreatableTypes());
list.AddRange("CreatableTypeList", GetCreatableTypes());
var viewModel = Shape.ViewModel()
.ContentTypes(list);

View File

@@ -36,6 +36,9 @@ namespace Orchard.Blogs.Commands {
[OrchardSwitch]
public string Slug { get; set; }
[OrchardSwitch]
public string Owner { get; set; }
[OrchardSwitch]
public string Title { get; set; }
@@ -43,17 +46,22 @@ namespace Orchard.Blogs.Commands {
public string MenuText { get; set; }
[CommandName("blog create")]
[CommandHelp("blog create /Slug:<slug> /Title:<title> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
[OrchardSwitches("Slug,Title,MenuText")]
[CommandHelp("blog create /Slug:<slug> /Title:<title> /Owner:<username> [/MenuText:<menu text>]\r\n\t" + "Creates a new Blog")]
[OrchardSwitches("Slug,Title,Owner,MenuText")]
public string Create() {
var admin = _membershipService.GetUser("admin");
var owner = _membershipService.GetUser(Owner);
if ( owner == null ) {
Context.Output.WriteLine();
return T("Invalid username: {0}", Owner).Text;
}
if(!IsSlugValid(Slug)) {
return "Invalid Slug provided. Blog creation failed.";
}
var blog = _contentManager.New("Blog");
blog.As<ICommonPart>().Owner = admin;
blog.As<ICommonPart>().Owner = owner;
blog.As<RoutePart>().Slug = Slug;
blog.As<RoutePart>().Path = Slug;
blog.As<RoutePart>().Title = Title;
@@ -68,10 +76,15 @@ namespace Orchard.Blogs.Commands {
}
[CommandName("blog import")]
[CommandHelp("blog import /Slug:<slug> /FeedUrl:<feed url>\r\n\t" + "Import all items from <feed url> into the blog at the specified <slug>")]
[OrchardSwitches("FeedUrl,Slug")]
[CommandHelp("blog import /Slug:<slug> /FeedUrl:<feed url> /Owner:<username>\r\n\t" + "Import all items from <feed url> into the blog at the specified <slug>")]
[OrchardSwitches("FeedUrl,Slug,Owner")]
public string Import() {
var admin = _membershipService.GetUser("admin");
var owner = _membershipService.GetUser(Owner);
if(owner == null) {
Context.Output.WriteLine();
return T("Invalid username: {0}", Owner).Text;
}
XDocument doc;
@@ -96,7 +109,7 @@ namespace Orchard.Blogs.Commands {
Context.Output.WriteLine("Adding post: {0}...", postName.Substring(0, Math.Min(postName.Length, 40)));
var post = _contentManager.New("BlogPost");
post.As<ICommonPart>().Owner = admin;
post.As<ICommonPart>().Owner = owner;
post.As<ICommonPart>().Container = blog;
var slug = Slugify(postName);
post.As<RoutePart>().Slug = slug;

View File

@@ -3,5 +3,6 @@ Author: The Orchard Team
Website: http://www.orchardproject.net
Description: Description for the theme
Version: 1.0
BaseTheme: $$BaseTheme$$
# todo: provide tags
# Tags: Classic, Serif

View File

@@ -19,12 +19,6 @@ namespace Orchard.CodeGeneration.Commands {
private readonly IExtensionManager _extensionManager;
private readonly ISchemaCommandGenerator _schemaCommandGenerator;
private static readonly string[] _ignoredExtensions = new [] {
"obj", "pdb", "exclude"
};
private static readonly string[] _ignoredPaths = new [] {
"/obj/"
};
private static readonly string[] _themeDirectories = new [] {
"", "Content", "Styles", "Scripts", "Views", "Zones"
};
@@ -35,6 +29,7 @@ namespace Orchard.CodeGeneration.Commands {
private const string ModuleName = "CodeGeneration";
private static readonly string _codeGenTemplatePath = HostingEnvironment.MapPath("~/Modules/Orchard." + ModuleName + "/CodeGenerationTemplates/");
private static readonly string _orchardWebProj = HostingEnvironment.MapPath("~/Orchard.Web.csproj");
private static readonly string _orchardThemesProj = HostingEnvironment.MapPath("~/Themes/Orchard.Themes.csproj");
public CodeGenerationCommands(
IExtensionManager extensionManager,
@@ -131,23 +126,23 @@ namespace Orchard.CodeGeneration.Commands {
}
[CommandName("generate create theme")]
[CommandHelp("generate create theme <theme-name> [/IncludeInSolution:true|false][/BasedOn:<theme-name>][]\r\n\tCreate a new Orchard theme")]
[CommandHelp("generate create theme <theme-name> [/CreateProject:true|false][/IncludeInSolution:true|false][/BasedOn:<theme-name>]\r\n\tCreate a new Orchard theme")]
[OrchardSwitches("IncludeInSolution,BasedOn,CreateProject")]
public void CreateTheme(string themeName) {
Context.Output.WriteLine(T("Creating Theme {0}", themeName));
if (_extensionManager.AvailableExtensions().Any(extension => String.Equals(themeName, extension.DisplayName, StringComparison.OrdinalIgnoreCase))) {
if (_extensionManager.AvailableExtensions().Any(extension => String.Equals(themeName, extension.Name, StringComparison.OrdinalIgnoreCase))) {
Context.Output.WriteLine(T("Creating Theme {0} failed: an extention of the same name already exists", themeName));
}
else {
string baseThemePath = null;
if (!string.IsNullOrEmpty(BasedOn)) {
baseThemePath = HostingEnvironment.MapPath("~/Themes/" + BasedOn + "/");
if (string.IsNullOrEmpty(baseThemePath) || !Directory.Exists(baseThemePath)) {
Context.Output.WriteLine(T("Creating Theme {0} failed: could not find base theme '{1}'", themeName, baseThemePath));
if (!_extensionManager.AvailableExtensions().Any(extension =>
string.Equals(extension.ExtensionType, "Theme", StringComparison.OrdinalIgnoreCase) &&
string.Equals(BasedOn, extension.Name, StringComparison.OrdinalIgnoreCase))) {
Context.Output.WriteLine(T("Creating Theme {0} failed: base theme named {1} was not found.", themeName, BasedOn));
return;
}
}
IntegrateTheme(themeName, baseThemePath);
IntegrateTheme(themeName, BasedOn);
Context.Output.WriteLine(T("Theme {0} created successfully", themeName));
}
}
@@ -209,10 +204,10 @@ namespace Orchard.CodeGeneration.Commands {
}
}
private void IntegrateTheme(string themeName, string baseThemePath) {
private void IntegrateTheme(string themeName, string baseTheme) {
CreateThemeFromTemplates(Context.Output, T,
themeName,
baseThemePath,
baseTheme,
CreateProject ? Guid.NewGuid().ToString().ToUpper() : null,
IncludeInSolution);
}
@@ -258,13 +253,7 @@ namespace Orchard.CodeGeneration.Commands {
return text;
}
private static bool IgnoreFile(string filePath) {
return String.IsNullOrEmpty(filePath) ||
_ignoredPaths.Any(filePath.Contains) ||
_ignoredExtensions.Contains(Path.GetExtension(filePath) ?? "");
}
private static void CreateThemeFromTemplates(TextWriter output, Localizer T, string themeName, string baseThemePath, string projectGuid, bool includeInSolution) {
private static void CreateThemeFromTemplates(TextWriter output, Localizer T, string themeName, string baseTheme, string projectGuid, bool includeInSolution) {
var themePath = HostingEnvironment.MapPath("~/Themes/" + themeName + "/");
var createdFiles = new HashSet<string>();
var createdFolders = new HashSet<string>();
@@ -277,44 +266,34 @@ namespace Orchard.CodeGeneration.Commands {
createdFolders.Add(folder);
}
}
if (baseThemePath != null) {
// copy BasedOn theme file by file
foreach (var file in Directory.GetFiles(baseThemePath, "*", SearchOption.AllDirectories)) {
// ignore dlls, etc
if (IgnoreFile(file)) {
continue;
}
var destPath = file.Replace(baseThemePath, themePath);
Directory.CreateDirectory(Path.GetDirectoryName(destPath));
File.Copy(file, destPath);
createdFiles.Add(destPath);
}
var webConfig = themePath + "Views\\Web.config";
File.WriteAllText(webConfig, File.ReadAllText(_codeGenTemplatePath + "\\ViewsWebConfig.txt"));
createdFiles.Add(webConfig);
var templateText = File.ReadAllText(_codeGenTemplatePath + "\\ThemeManifest.txt").Replace("$$ThemeName$$", themeName);
if (string.IsNullOrEmpty(baseTheme)) {
templateText = templateText.Replace("BaseTheme: $$BaseTheme$$\r\n", "");
}
else {
// non-BasedOn theme default files
var webConfig = themePath + "Views\\Web.config";
File.WriteAllText(webConfig, File.ReadAllText(_codeGenTemplatePath + "\\ViewsWebConfig.txt"));
createdFiles.Add(webConfig);
templateText = templateText.Replace("$$BaseTheme$$", baseTheme);
}
var templateText = File.ReadAllText(_codeGenTemplatePath + "\\ThemeManifest.txt").Replace("$$ThemeName$$", themeName);
File.WriteAllText(themePath + "Theme.txt", templateText);
createdFiles.Add(themePath + "Theme.txt");
string itemGroup = null;
if (projectGuid != null || includeInSolution) {
itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders);
}
// create new csproj for the theme
if (projectGuid != null) {
var itemGroup = CreateProjectItemGroup(themePath, createdFiles, createdFolders);
string projectText = CreateCsProject(themeName, projectGuid, itemGroup);
File.WriteAllText(themePath + "\\" + themeName + ".csproj", projectText);
}
if (includeInSolution) {
if (projectGuid == null) {
// include in solution but dont create a project: just add the references to Orchard.Web
AddFilesToOrchardWeb(output, T, itemGroup);
// include in solution but dont create a project: just add the references to Orchard.Themes project
var itemGroup = CreateProjectItemGroup(HostingEnvironment.MapPath("~/Themes/"), createdFiles, createdFolders);
AddFilesToOrchardThemesProject(output, T, itemGroup);
}
else {
// create a project (already done) and add it to the solution
@@ -363,12 +342,12 @@ namespace Orchard.CodeGeneration.Commands {
return string.Format(CultureInfo.InvariantCulture, "<ItemGroup>\r\n{0}\r\n </ItemGroup>\r\n ", contentInclude);
}
private static void AddFilesToOrchardWeb(TextWriter output, Localizer T, string itemGroup) {
if (!File.Exists(_orchardWebProj)) {
output.WriteLine(T("Warning: Orchard.Web project file could not be found at {0}", _orchardWebProj));
private static void AddFilesToOrchardThemesProject(TextWriter output, Localizer T, string itemGroup) {
if (!File.Exists(_orchardThemesProj)) {
output.WriteLine(T("Warning: Orchard.Themes project file could not be found at {0}", _orchardThemesProj));
}
else {
var projectText = File.ReadAllText(_orchardWebProj);
var projectText = File.ReadAllText(_orchardThemesProj);
// find where the first ItemGroup is after any References
var refIndex = projectText.LastIndexOf("<Reference Include");
@@ -376,11 +355,11 @@ namespace Orchard.CodeGeneration.Commands {
var firstItemGroupIndex = projectText.IndexOf("<ItemGroup>", refIndex);
if (firstItemGroupIndex != -1) {
projectText = projectText.Insert(firstItemGroupIndex, itemGroup);
File.WriteAllText(_orchardWebProj, projectText);
File.WriteAllText(_orchardThemesProj, projectText);
return;
}
}
output.WriteLine(T("Warning: Unable to modify Orchard.Web project file at {0}", _orchardWebProj));
output.WriteLine(T("Warning: Unable to modify Orchard.Themes project file at {0}", _orchardThemesProj));
}
}

View File

@@ -22,7 +22,7 @@ namespace Orchard.Experimental.Controllers {
}
public ActionResult Execute() {
return View(new CommandsExecuteViewModel());
return View("Execute", new CommandsExecuteViewModel());
}
[HttpPost]

View File

@@ -59,7 +59,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="ResourceManifest.cs" />
<Compile Include="Commands\IndexingCommands.cs" />
<Compile Include="Controllers\AdminController.cs" />
<Compile Include="Migrations.cs" />
@@ -100,6 +99,7 @@
<Content Include="Views\DefinitionTemplates\FieldIndexing.cshtml" />
<Content Include="Views\DefinitionTemplates\TypeIndexing.cshtml" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<ProjectExtensions>

View File

@@ -1,13 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Orchard.UI.Resources;
namespace Orchard.Indexing {
public class ResourceManifest : IResourceManifestProvider {
public void BuildManifests(ResourceManifestBuilder builder) {
builder.Add().DefineStyle("IndexingAdmin").SetUrl("admin.css"); // todo: this does not exist
}
}
}

View File

@@ -1,5 +1,4 @@
@model Orchard.Indexing.ViewModels.IndexViewModel
@{ Style.Require("IndexingAdmin"); }
<h1>@Html.TitleForPage(T("Search Index Management").ToString())</h1>
@using (Html.BeginForm("update", "admin", FormMethod.Post, new {area = "Orchard.Indexing"})) {

View File

@@ -107,7 +107,7 @@ namespace Orchard.Packaging.Controllers {
public ActionResult Modules(Guid? sourceId) {
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
return View(new PackagingModulesViewModel {
return View("Modules", new PackagingModulesViewModel {
Modules = _packagingSourceManager.GetModuleList(selectedSource).Where(p => p.SyndicationItem.Categories.All(c => c.Name == "Orchard Module" || c.Name != "Orchard Theme")),
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
SelectedSource = selectedSource
@@ -117,7 +117,7 @@ namespace Orchard.Packaging.Controllers {
public ActionResult Themes(Guid? sourceId) {
var selectedSource = _packagingSourceManager.GetSources().Where(s => s.Id == sourceId).FirstOrDefault();
return View(new PackagingModulesViewModel {
return View("Themes", new PackagingModulesViewModel {
Modules = _packagingSourceManager.GetModuleList(selectedSource).Where(p => p.SyndicationItem.Categories.Any(c => c.Name == "Orchard Theme")),
Sources = _packagingSourceManager.GetSources().OrderBy(s => s.FeedTitle),
SelectedSource = selectedSource

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Orchard.Core.Contents.Controllers;
using Orchard.Localization;
using Orchard.Roles.Models;
using Orchard.Roles.Services;
@@ -98,9 +99,9 @@ namespace Orchard.Roles.Controllers {
var role = _roleService.GetRole(id);
if (role == null) {
//TODO: Error message
throw new HttpException(404, "page with id " + id + " was not found");
return HttpNotFound();
}
var model = new RoleEditViewModel { Name = role.Name, Id = role.Id,
RoleCategoryPermissions = _roleService.GetInstalledPermissions(),
CurrentPermissions = _roleService.GetPermissionsForRole(id)};
@@ -117,7 +118,8 @@ namespace Orchard.Roles.Controllers {
}
[HttpPost, ActionName("Edit")]
public ActionResult EditPOST() {
[FormValueRequired("submit.Save")]
public ActionResult EditSavePOST(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
@@ -125,24 +127,38 @@ namespace Orchard.Roles.Controllers {
try {
UpdateModel(viewModel);
// Save
if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Save"])) {
List<string> rolePermissions = new List<string>();
foreach (string key in Request.Form.Keys) {
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
string permissionName = key.Substring("Checkbox.".Length);
rolePermissions.Add(permissionName);
}
List<string> rolePermissions = new List<string>();
foreach (string key in Request.Form.Keys) {
if (key.StartsWith("Checkbox.") && Request.Form[key] == "true") {
string permissionName = key.Substring("Checkbox.".Length);
rolePermissions.Add(permissionName);
}
_roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions);
}
else if (!String.IsNullOrEmpty(HttpContext.Request.Form["submit.Delete"])) {
_roleService.DeleteRole(viewModel.Id);
}
return RedirectToAction("Edit", new { viewModel.Id });
_roleService.UpdateRole(viewModel.Id, viewModel.Name, rolePermissions);
Services.Notifier.Information(T("Your Role has been saved."));
return RedirectToAction("Edit", new { id });
}
catch (Exception exception) {
Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message));
return RedirectToAction("Edit", viewModel.Id);
return RedirectToAction("Edit", id);
}
}
[HttpPost, ActionName("Edit")]
[FormValueRequired("submit.Delete")]
public ActionResult EditDeletePOST(int id) {
if (!Services.Authorizer.Authorize(Permissions.ManageRoles, T("Not authorized to manage roles")))
return new HttpUnauthorizedResult();
try {
_roleService.DeleteRole(id);
Services.Notifier.Information(T("Role was successfully deleted."));
return RedirectToAction("Index");
} catch (Exception exception) {
Services.Notifier.Error(T("Editing Role failed: {0}", exception.Message));
return RedirectToAction("Edit", id);
}
}
}

View File

@@ -103,6 +103,10 @@
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

View File

@@ -9,24 +9,24 @@
<select id="Select1" name="roleActions">
<option value="1">@T("Remove")</option>
</select>
<input class="button" type="submit" value="@T("Apply")" />
</fieldset>
<input class="button" type="submit" value="@T("Apply")" />
</fieldset>
<div class="manage">@Html.ActionLink(T("Add a role").ToString(), "Create", new { }, new { @class = "button primaryAction" })</div>
<fieldset>
<table class="items" summary="@T("This is a table of the roles currently available for use in your application.")">
<colgroup>
<col id="Col1" />
<col id="Col2" />
<col id="Col3" />
</colgroup>
<thead>
<tr>
<th scope="col">&nbsp;&darr;</th>
<th scope="col">@T("Name")</th>
<th scope="col"></th>
</tr>
</thead>
@foreach (var row in Model.Rows) {
<col id="Col2" />
<col id="Col3" />
</colgroup>
<thead>
<tr>
<th scope="col">&nbsp;&darr;</th>
<th scope="col">@T("Name")</th>
<th scope="col"></th>
</tr>
</thead>
@foreach (var row in Model.Rows) {
<tr>
<td><input type="checkbox" value="true" name="@("Checkbox." + row.Id)"/></td>
<td>@row.Name</td>
@@ -34,7 +34,5 @@
</tr>
}
</table>
</fieldset>
}

View File

@@ -44,9 +44,10 @@ namespace Orchard.Widgets.Controllers {
layers.First() :
layers.FirstOrDefault(layer => layer.Id == id);
if (currentLayer == null) {
if (currentLayer == null &&
id != null) {
// Incorrect layer id passed
Services.Notifier.Error(T("Layer not found: {1}", id));
Services.Notifier.Error(T("Layer not found: {0}", id));
return RedirectToAction("Index");
}
@@ -254,7 +255,7 @@ namespace Orchard.Widgets.Controllers {
try {
widgetPart = _widgetsService.GetWidget(id);
if (widgetPart == null) {
Services.Notifier.Error(T("Widget not found: {1}", id));
Services.Notifier.Error(T("Widget not found: {0}", id));
return RedirectToAction("Index");
}

View File

@@ -40,6 +40,10 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\lib\aspnetmvc\System.Web.Mvc.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -479,22 +479,14 @@ ul.comments li div.text {
/*border:1px solid #ff0000;*/
}
/* If zones 1 and 2 are empty in the quad */
/* If zone 1 is empty and 2, 3, 4 are not */
.split-234 #footer-quad-second div.zone { width:480px; }
.split-left #footer-quad-third div.zone {
width:600px;
}
/* If zone 2 is empty and 1, 3, 4 are not */
.split-134 #footer-quad-first div.zone { width:480px; }
.split-left #footer-quad-fourth div.zone {
width:360px;
}
/* If zone 3 is empty and 1, 2, 4 are not */
.split-124 #footer-quad-fourth div.zone { width:480px; }
/* If zones 3 and 4 are empty in the quad */
.split-right #footer-quad-first div.zone {
width:600px;
}
.split-right #footer-quad-second div.zone {
width:360px;
}
/* If zone 4 is empty and 1, 2, 3 are not */
.split-123 #footer-quad-third div.zone { width:480px; }

View File

@@ -21,13 +21,25 @@
else {
}
// Debug Quad
// {WorkContext.Layout.FooterQuadSecond.Add("2 This is some test text to see if zones are working. This is some test text to see if zones are working.");}
// {WorkContext.Layout.FooterQuadFirst.Add("1 This is some test text to see if zones are working. This is some test text to see if zones are working.");}
// {WorkContext.Layout.FooterQuadThird.Add("3 This is some test text to see if zones are working. This is some test text to see if zones are working.");}
//Add classes to the wrapper div to toggle quad widget zones on and off
if (Model.FooterQuadFirst == null && Model.FooterQuadSecond == null) {
Model.Classes.Add("split-left");
if (Model.FooterQuadFirst == null && Model.FooterQuadSecond != null && Model.FooterQuadThird != null && Model.FooterQuadFourth != null) {
Model.Classes.Add("split-234");
}
else if (Model.FooterQuadThird == null && Model.FooterQuadFourth == null) {
Model.Classes.Add("split-right");
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond == null && Model.FooterQuadThird != null && Model.FooterQuadFourth != null) {
Model.Classes.Add("split-134");
}
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond != null && Model.FooterQuadThird == null && Model.FooterQuadFourth != null) {
Model.Classes.Add("split-124");
}
else if (Model.FooterQuadFirst != null && Model.FooterQuadSecond != null && Model.FooterQuadThird != null && Model.FooterQuadFourth == null) {
Model.Classes.Add("split-123");
}
else {

View File

@@ -35,30 +35,12 @@ namespace Orchard.Environment.Extensions {
return _folders.SelectMany(folder => folder.AvailableExtensions());
}
public IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor) {
var enabledFeatures = EnabledFeatures(descriptor);
return _folders.SelectMany(folder => folder.AvailableExtensions())
.Where(extensionDescriptor =>
extensionDescriptor.Features.Any(featureDescriptor =>
enabledFeatures.Any(availableFeature => featureDescriptor.Name == availableFeature.Name)));
}
public IEnumerable<FeatureDescriptor> AvailableFeatures() {
var featureDescriptors = AvailableExtensions().SelectMany(ext => ext.Features);
var featureDescriptorsOrdered = featureDescriptors.OrderByDependencies(HasDependency);
return featureDescriptorsOrdered.ToReadOnlyCollection();
}
public IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor) {
return AvailableExtensions()
.SelectMany(extensionDescriptor => extensionDescriptor.Features)
.Where(featureDescriptor => IsFeatureEnabledInDescriptor(featureDescriptor, descriptor));
}
private static bool IsFeatureEnabledInDescriptor(FeatureDescriptor featureDescriptor, ShellDescriptor shellDescriptor) {
return shellDescriptor.Features.Any(shellDescriptorFeature => shellDescriptorFeature.Name == featureDescriptor.Name);
}
/// <summary>
/// Returns true if the item has an explicit or implicit dependency on the subject
/// </summary>

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.Environment.Descriptor.Models;
using Orchard.Environment.Extensions.Models;
@@ -6,12 +7,30 @@ using Orchard.Environment.Extensions.Models;
namespace Orchard.Environment.Extensions {
public interface IExtensionManager {
IEnumerable<ExtensionDescriptor> AvailableExtensions();
IEnumerable<ExtensionDescriptor> EnabledExtensions(ShellDescriptor descriptor);
IEnumerable<FeatureDescriptor> AvailableFeatures();
IEnumerable<FeatureDescriptor> EnabledFeatures(ShellDescriptor descriptor);
IEnumerable<Feature> LoadFeatures(IEnumerable<FeatureDescriptor> featureDescriptors);
void InstallExtension(string extensionType, HttpPostedFileBase extensionBundle);
void UninstallExtension(string extensionType, string extensionName);
}
}
public static class ExtensionManagerExtensions {
public static IEnumerable<ExtensionDescriptor> EnabledExtensions(this IExtensionManager extensionManager, ShellDescriptor descriptor) {
var enabledFeatures = EnabledFeatures(extensionManager, descriptor);
return extensionManager.AvailableExtensions()
.Where(extensionDescriptor =>
extensionDescriptor.Features.Any(featureDescriptor =>
enabledFeatures.Any(availableFeature => featureDescriptor.Name == availableFeature.Name)));
}
public static IEnumerable<FeatureDescriptor> EnabledFeatures(this IExtensionManager extensionManager, ShellDescriptor descriptor) {
return extensionManager.AvailableExtensions()
.SelectMany(extensionDescriptor => extensionDescriptor.Features)
.Where(featureDescriptor => IsFeatureEnabledInDescriptor(featureDescriptor, descriptor));
}
private static bool IsFeatureEnabledInDescriptor(FeatureDescriptor featureDescriptor, ShellDescriptor shellDescriptor) {
return shellDescriptor.Features.Any(shellDescriptorFeature => shellDescriptorFeature.Name == featureDescriptor.Name);
}
}
}