Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions Toders.FindMyContent/Controllers/FindMyContentController.cs
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Editor;
using EPiServer.PlugIn;
using EPiServer.ServiceLocation;
using EPiServer.Shell.Modules;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Toders.FindMyContent.Core;
using Toders.FindMyContent.Models.FindMyContent;

namespace Toders.FindMyContent.Controllers
{
[GuiPlugIn(
Area = PlugInArea.AdminMenu,
Url = "/FindMyContent/",
DisplayName = "Find My Content")]
[Authorize(Roles = "CmsAdmins")]
public class FindMyContentController : Controller
{
private readonly IContentTypeRepository _contentTypeRepository;
private readonly IContentFinder _contentFinder;

public FindMyContentController()
: this(ServiceLocator.Current.GetInstance<IContentTypeRepository>(),
ServiceLocator.Current.GetInstance<IContentFinder>())
{
}
private readonly ProtectedModuleOptions _protectedModuleOptions;

public FindMyContentController(
IContentTypeRepository contentTypeRepository,
IContentFinder contentFinder)
IContentFinder contentFinder,
ProtectedModuleOptions protectedModuleOptions)
{
_contentTypeRepository = contentTypeRepository;
_contentFinder = contentFinder;
_protectedModuleOptions = protectedModuleOptions;
}

[Route("FindMyContent")]
[HttpGet]
public ActionResult Index()
{
var contentTypes = _contentTypeRepository.List()
Expand Down Expand Up @@ -65,9 +61,11 @@ public ActionResult Index()
EditUrls = contentTypes.ToDictionary(x => x.Id, CreateEditContentTypeUrl)
};

return View(string.Empty, model);
return View(model);
}

[Route("FindMyContent/Details/{id}")]
[HttpGet]
public ActionResult Details(int id)
{
ContentType contentType = _contentTypeRepository.Load(id);
Expand All @@ -81,7 +79,7 @@ public ActionResult Details(int id)
}).ToList()
};

return View(string.Empty, model);
return View(model);
}

private Dictionary<string, string> CreateEditContentUrls(ContentSummary contentSummary)
Expand All @@ -93,9 +91,8 @@ private Dictionary<string, string> CreateEditContentUrls(ContentSummary contentS

private string CreateEditContentTypeUrl(ContentTypeModel contentTypeModel)
{
var urlBuilder = new UrlBuilder(UriSupport.AbsoluteUrlFromUIBySettings("Admin/EditContentType.aspx"));
urlBuilder.QueryCollection["typeId"] = contentTypeModel.Id.ToString();
return urlBuilder.ToString();
var rootPath = _protectedModuleOptions.RootPath.Replace("~", string.Empty);
return Path.Join(rootPath, $"/EPiServer.Cms.UI.Admin/default#/ContentTypes/edit-content-type/{contentTypeModel.Id}");
}

private ContentTypeModel CreateContentTypeModel(ContentType contentType)
Expand Down
8 changes: 4 additions & 4 deletions Toders.FindMyContent/Core/ContentFinder.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using EPiServer;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.ServiceLocation;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

namespace Toders.FindMyContent.Core
{
Expand Down
4 changes: 2 additions & 2 deletions Toders.FindMyContent/Core/ContentSummary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using EPiServer.Core;
using EPiServer.Core;
using System.Collections.Generic;

namespace Toders.FindMyContent.Core
{
Expand Down
30 changes: 0 additions & 30 deletions Toders.FindMyContent/Core/InitializationModule.cs

This file was deleted.

20 changes: 20 additions & 0 deletions Toders.FindMyContent/FindMyContentMenuProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using EPiServer.Shell.Navigation;
using System.Collections.Generic;

namespace Toders.FindMyContent
{
[MenuProvider]
public class FindMyContentMenuProvider : IMenuProvider
{
public IEnumerable<MenuItem> GetMenuItems()
{
return new List<MenuItem>(1)
{
new UrlMenuItem("Find My Content", "/global/cms/admin/findmycontent", "/FindMyContent/") {
IsAvailable = context => true,
SortIndex = 100,
}
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public class ContentSummaryModel
{
public ContentSummary Summary { get; set; }

public Dictionary<string, string> EditUrls { get; set; }
public Dictionary<string, string> EditUrls { get; set; }
}
}
1 change: 0 additions & 1 deletion Toders.FindMyContent/Models/FindMyContent/DetailsModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Toders.FindMyContent.Core;

namespace Toders.FindMyContent.Models.FindMyContent
{
Expand Down
Loading