2018-09-20 17:22:39 +02:00
|
|
|
|
using System;
|
2018-10-14 15:56:22 +01:00
|
|
|
|
using System.Collections.Generic;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
using Umbraco.Core.Models;
|
|
|
|
|
|
using Umbraco.Core.Models.ContentEditing;
|
2018-10-14 15:56:22 +01:00
|
|
|
|
using Umbraco.Core.Models.Membership;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Web.ContentApps
|
|
|
|
|
|
{
|
2018-12-06 10:02:23 +01:00
|
|
|
|
internal class ContentEditorContentAppFactory : IContentAppFactory
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
2018-09-21 09:42:36 +02:00
|
|
|
|
// see note on ContentApp
|
2019-04-23 21:31:48 +02:00
|
|
|
|
internal const int Weight = -100;
|
2018-09-21 09:42:36 +02:00
|
|
|
|
|
2018-09-20 17:22:39 +02:00
|
|
|
|
private ContentApp _contentApp;
|
|
|
|
|
|
private ContentApp _mediaApp;
|
|
|
|
|
|
|
2018-10-14 15:56:22 +01:00
|
|
|
|
public ContentApp GetContentAppFor(object o, IEnumerable<IReadOnlyUserGroup> userGroups)
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
|
|
|
|
|
switch (o)
|
|
|
|
|
|
{
|
|
|
|
|
|
case IContent _:
|
|
|
|
|
|
return _contentApp ?? (_contentApp = new ContentApp
|
|
|
|
|
|
{
|
|
|
|
|
|
Alias = "umbContent",
|
|
|
|
|
|
Name = "Content",
|
|
|
|
|
|
Icon = "icon-document",
|
2018-09-21 09:42:36 +02:00
|
|
|
|
View = "views/content/apps/content/content.html",
|
|
|
|
|
|
Weight = Weight
|
2018-09-20 17:22:39 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
2019-02-27 19:56:37 +01:00
|
|
|
|
case IMedia media when !media.ContentType.IsContainer || media.Properties.Count > 0:
|
2018-09-20 17:22:39 +02:00
|
|
|
|
return _mediaApp ?? (_mediaApp = new ContentApp
|
|
|
|
|
|
{
|
|
|
|
|
|
Alias = "umbContent",
|
|
|
|
|
|
Name = "Content",
|
|
|
|
|
|
Icon = "icon-document",
|
2018-09-21 09:42:36 +02:00
|
|
|
|
View = "views/media/apps/content/content.html",
|
|
|
|
|
|
Weight = Weight
|
2018-09-20 17:22:39 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
case IMedia _:
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new NotSupportedException($"Object type {o.GetType()} is not supported here.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|