2021-02-18 11:06:02 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models.ContentEditing;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models.Membership;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
|
namespace Umbraco.Cms.Core.ContentApps
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
2020-04-01 15:50:46 +02:00
|
|
|
|
public 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
|
|
|
|
|
2021-12-16 13:44:20 +01:00
|
|
|
|
private ContentApp? _contentApp;
|
|
|
|
|
|
private ContentApp? _mediaApp;
|
|
|
|
|
|
private ContentApp? _memberApp;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
|
2021-12-16 13:44:20 +01:00
|
|
|
|
public ContentApp? GetContentAppFor(object o, IEnumerable<IReadOnlyUserGroup> userGroups)
|
2018-09-20 17:22:39 +02:00
|
|
|
|
{
|
|
|
|
|
|
switch (o)
|
|
|
|
|
|
{
|
2019-04-30 21:34:00 +02:00
|
|
|
|
case IContent content when content.Properties.Count > 0:
|
2018-09-20 17:22:39 +02:00
|
|
|
|
return _contentApp ?? (_contentApp = new ContentApp
|
|
|
|
|
|
{
|
|
|
|
|
|
Alias = "umbContent",
|
|
|
|
|
|
Name = "Content",
|
2019-06-07 17:02:55 +01:00
|
|
|
|
Icon = Constants.Icons.Content,
|
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",
|
2019-06-07 17:02:55 +01:00
|
|
|
|
Icon = Constants.Icons.Content,
|
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
|
|
|
|
});
|
|
|
|
|
|
|
2019-12-18 10:43:41 +01:00
|
|
|
|
case IMember _:
|
|
|
|
|
|
return _memberApp ?? (_memberApp = new ContentApp
|
|
|
|
|
|
{
|
|
|
|
|
|
Alias = "umbContent",
|
|
|
|
|
|
Name = "Content",
|
|
|
|
|
|
Icon = Constants.Icons.Content,
|
|
|
|
|
|
View = "views/member/apps/content/content.html",
|
|
|
|
|
|
Weight = Weight
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2018-09-20 17:22:39 +02:00
|
|
|
|
default:
|
2020-06-19 19:10:16 +02:00
|
|
|
|
return null;
|
2018-09-20 17:22:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|