diff --git a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields.Common.Text.Edit.cshtml b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields.Common.Text.Edit.cshtml
index 833887b1a..eb917bddc 100644
--- a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields.Common.Text.Edit.cshtml
+++ b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Fields.Common.Text.Edit.cshtml
@@ -7,7 +7,7 @@
@Html.ValidationMessageFor(m => m.Text)
}
else {
- @Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem)
+ @Display.Body_Editor(Text: Model.Text, EditorFlavor: Model.Settings.Flavor, Required: Model.Settings.Required, ContentItem: Model.ContentItem, Field: Model.Field)
}
@if (HasText(Model.Settings.Hint)) {
@Model.Settings.Hint
diff --git a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts.Common.Body.cshtml b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts.Common.Body.cshtml
index 1e3e488a6..785d436ee 100644
--- a/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts.Common.Body.cshtml
+++ b/src/Orchard.Web/Core/Common/Views/EditorTemplates/Parts.Common.Body.cshtml
@@ -2,6 +2,6 @@
@using Orchard.Core.Common.ViewModels;
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs
index 09d877c5b..eb62d7616 100644
--- a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs
+++ b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/HtmlElementDriver.cs
@@ -15,7 +15,8 @@ namespace Orchard.Layouts.Drivers {
protected override EditorResult OnBuildEditor(Html element, ElementEditorContext context) {
var viewModel = new HtmlEditorViewModel {
- Text = element.Content
+ Text = element.Content,
+ Part = ((dynamic)context.Content.ContentItem).LayoutPart
};
var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Html", Model: viewModel);
diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/HtmlEditorViewModel.cs b/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/HtmlEditorViewModel.cs
index dc64dab09..ab84b1465 100644
--- a/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/HtmlEditorViewModel.cs
+++ b/src/Orchard.Web/Modules/Orchard.Layouts/ViewModels/HtmlEditorViewModel.cs
@@ -1,5 +1,8 @@
-namespace Orchard.Layouts.ViewModels {
+using Orchard.ContentManagement;
+
+namespace Orchard.Layouts.ViewModels {
public class HtmlEditorViewModel {
public string Text { get; set; }
+ public ContentPart Part { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Html.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Html.cshtml
index 1df31b732..32bbe1ee9 100644
--- a/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Html.cshtml
+++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/EditorTemplates/Elements.Html.cshtml
@@ -1,5 +1,5 @@
@model Orchard.Layouts.ViewModels.HtmlEditorViewModel
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/Orchard.Tokens/Providers/ContentTokens.cs b/src/Orchard.Web/Modules/Orchard.Tokens/Providers/ContentTokens.cs
index fb26b2500..e6ddfe22f 100644
--- a/src/Orchard.Web/Modules/Orchard.Tokens/Providers/ContentTokens.cs
+++ b/src/Orchard.Web/Modules/Orchard.Tokens/Providers/ContentTokens.cs
@@ -26,6 +26,9 @@ namespace Orchard.Tokens.Providers {
public Localizer T { get; set; }
public void Describe(DescribeContext context) {
+ context.For("ContentItem", T("Content Items"), T("The context to access specific content items."))
+ .Token("Id:*", T("Content Item by Id"), T("The content item with the specified id."));
+
context.For("Content", T("Content Items"), T("Content Items"))
.Token("Id", T("Content Id"), T("Numeric primary key value of content."))
.Token("Author", T("Content Author"), T("Person in charge of the content."), "User")
@@ -36,8 +39,7 @@ namespace Orchard.Tokens.Providers {
.Token("DisplayUrl", T("Display Url"), T("Url to display the content."), "Url")
.Token("EditUrl", T("Edit Url"), T("Url to edit the content."), "Url")
.Token("Container", T("Container"), T("The container Content Item."), "Content")
- .Token("Body", T("Body"), T("The body text of the content item."), "Text")
- ;
+ .Token("Body", T("Body"), T("The body text of the content item."), "Text");
// Token descriptors for fields
foreach (var typeDefinition in _contentManager.GetContentTypeDefinitions()) {
@@ -72,26 +74,57 @@ namespace Orchard.Tokens.Providers {
}
public void Evaluate(EvaluateContext context) {
+ context.For("ContentItem", _contentManager)
+ .Token(
+ token => token.StartsWith("Id:", StringComparison.OrdinalIgnoreCase) ? ContentManagerGetToken(token) : "",
+ (token, cm) => {
+ // token is Id:*
+ if (token != "") {
+ var id = token.Substring("Id:".Length);
+ return cm.Get(Convert.ToInt32(id));
+ }
+ else { return null; }
+ })
+ .Chain(
+ token => {
+ var cleanToken = ContentManagerGetToken(token); // is Id:*
+ if (string.IsNullOrWhiteSpace(cleanToken)) return null;
+ int cleanTokenLength = cleanToken.Length;
+ var subTokens = token.Length > cleanTokenLength ? token.Substring(cleanToken.Length + 1) : "";
+ return new Tuple(
+ cleanToken, //The specific Token Id:*, it is the key
+ subTokens //The subsequent Tokens (i.e Fields.PartName.FieldName)
+ );
+ },
+ "Content",
+ (token, cm) => {
+ // token is Id:*
+
+ if (token != "") {
+ var id = token.Substring("Id:".Length);
+ return cm.Get(Convert.ToInt32(id));
+ }
+ else { return null; }
+ });
context.For("Content")
- .Token("Id", content => content != null ? content.Id : 0)
- .Token("Author", AuthorName)
- .Chain("Author", "User", content => content != null ? content.As().Owner : null)
- .Token("Date", Date)
- .Chain("Date", "Date", Date)
- .Token("Identity", content => content != null ? _contentManager.GetItemMetadata(content).Identity.ToString() : String.Empty)
- .Token("ContentType", content => content != null ? content.ContentItem.TypeDefinition.DisplayName : String.Empty)
- .Chain("ContentType", "TypeDefinition", content => content != null ? content.ContentItem.TypeDefinition : null)
- .Token("DisplayText", DisplayText)
- .Chain("DisplayText", "Text", DisplayText)
- .Token("DisplayUrl", DisplayUrl)
- .Chain("DisplayUrl", "Url", DisplayUrl)
- .Token("EditUrl", EditUrl)
- .Chain("EditUrl", "Url", EditUrl)
- .Token("Container", content => DisplayText(Container(content)))
- .Chain("Container", "Content", Container)
- .Token("Body", Body)
- .Chain("Body", "Text", Body)
- ;
+ .Token("Id", content => content != null ? content.Id : 0)
+ .Token("Author", AuthorName)
+ .Chain("Author", "User", content => content != null ? content.As().Owner : null)
+ .Token("Date", Date)
+ .Chain("Date", "Date", Date)
+ .Token("Identity", content => content != null ? _contentManager.GetItemMetadata(content).Identity.ToString() : String.Empty)
+ .Token("ContentType", content => content != null ? content.ContentItem.TypeDefinition.DisplayName : String.Empty)
+ .Chain("ContentType", "TypeDefinition", content => content != null ? content.ContentItem.TypeDefinition : null)
+ .Token("DisplayText", DisplayText)
+ .Chain("DisplayText", "Text", DisplayText)
+ .Token("DisplayUrl", DisplayUrl)
+ .Chain("DisplayUrl", "Url", DisplayUrl)
+ .Token("EditUrl", EditUrl)
+ .Chain("EditUrl", "Url", EditUrl)
+ .Token("Container", content => DisplayText(Container(content)))
+ .Chain("Container", "Content", Container)
+ .Token("Body", Body)
+ .Chain("Body", "Text", Body);
if (context.Target == "Content") {
var forContent = context.For("Content");
@@ -201,5 +234,36 @@ namespace Orchard.Tokens.Providers {
return bodyPart.Text;
}
+
+ //returns Id:* Token
+ private static string ContentManagerGetToken(string token) {
+ string tokenPrefix, result;
+ int chainIndex, tokenLength;
+
+ if (token.IndexOf(":") == -1) {
+ return null;
+ }
+ tokenPrefix = token.Substring(0, token.IndexOf(":"));
+
+ chainIndex = token.IndexOf(".");
+ tokenLength = (tokenPrefix + ":").Length;
+ if (!token.StartsWith((tokenPrefix + ":"), StringComparison.OrdinalIgnoreCase) || chainIndex <= tokenLength) {
+ return null;
+ }
+ else if (chainIndex == 0) {// "." has not be found
+ result = token.Substring(tokenLength);
+ }
+ else {
+ result = token.Substring(0, chainIndex);
+ }
+
+ // return the resulting id if it is a number, otherwise an empty string
+ if (int.TryParse(result.Substring(tokenPrefix.Length + 1), out var contentid)) {
+ return result;
+ }
+ else {
+ return "";
+ }
+ }
}
}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/orchard-tinymce.js b/src/Orchard.Web/Modules/TinyMce/Scripts/orchard-tinymce.js
index e16c6b4bb..a64fd45a1 100644
--- a/src/Orchard.Web/Modules/TinyMce/Scripts/orchard-tinymce.js
+++ b/src/Orchard.Web/Modules/TinyMce/Scripts/orchard-tinymce.js
@@ -1,4 +1,6 @@
var mediaPlugins = "";
+var contentPickerPlugins = "";
+var contentPickerButtons = "";
if (mediaPickerEnabled) {
mediaPlugins += " mediapicker";
@@ -8,14 +10,19 @@ if (mediaLibraryEnabled) {
mediaPlugins += " medialibrary";
}
+if (contenPickerEnabled && tokensHtmlFilterEnabled) {
+ contentPickerPlugins += " orchardcontentlinks"
+ contentPickerButtons += "orchardlink"
+}
+
tinyMCE.init({
selector: "textarea.tinymce",
theme: "modern",
schema: "html5",
plugins: [
- "advlist, anchor, autolink, autoresize, charmap, code, colorpicker, contextmenu, directionality, emoticons, fullscreen, hr, image, insertdatetime, link, lists, media, nonbreaking, pagebreak, paste, preview, print, searchreplace, table, template, textcolor, textpattern, visualblocks, visualchars, wordcount, htmlsnippets" + mediaPlugins
+ "advlist, anchor, autolink, autoresize, charmap, code, colorpicker, contextmenu, directionality, emoticons, fullscreen, hr, image, insertdatetime, link, lists, media, nonbreaking, pagebreak, paste, preview, print, searchreplace, table, template, textcolor, textpattern, visualblocks, visualchars, wordcount, htmlsnippets" + (contentPickerPlugins != "" ? ", " + contentPickerPlugins : "") + (mediaPlugins != "" ? ", " + mediaPlugins : "")
],
- toolbar: "undo redo cut copy paste | bold italic | bullist numlist outdent indent formatselect | alignleft aligncenter alignright alignjustify ltr rtl | " + mediaPlugins + " link unlink charmap | code htmlsnippetsbutton fullscreen",
+ toolbar: "undo redo cut copy paste | bold italic | bullist numlist outdent indent formatselect | alignleft aligncenter alignright alignjustify ltr rtl | " + mediaPlugins + " link " + contentPickerButtons + " unlink charmap | code htmlsnippetsbutton fullscreen",
convert_urls: false,
valid_elements: "*[*]",
// Shouldn't be needed due to the valid_elements setting, but TinyMCE would strip script.src without it.
@@ -27,7 +34,7 @@ tinyMCE.init({
auto_focus: autofocus,
directionality: directionality,
setup: function (editor) {
- $(document).bind("localization.ui.directionalitychanged", function(event, directionality) {
+ $(document).bind("localization.ui.directionalitychanged", function (event, directionality) {
editor.getBody().dir = directionality;
});
diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.js b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.js
new file mode 100644
index 000000000..b76b79b86
--- /dev/null
+++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.js
@@ -0,0 +1,54 @@
+tinymce.PluginManager.add('orchardcontentlinks', function (editor, url) {
+ var contentPickerAction = function () {
+ var data = {};
+ var callbackName = "_contentpicker_" + new Date().getTime();
+ data.callbackName = callbackName;
+ $[callbackName] = function (returnData) {
+ delete $[callbackName];
+ //the code to wrap text with link
+ var textLink = editor.selection.getContent();
+ if (!textLink || textLink == "") {
+ textLink = returnData.displayText;
+ }
+ editor.insertContent("" + textLink + "");
+
+ };
+ $[callbackName].data = data;
+
+ // Open content picker window
+ var baseUrl = baseOrchardPath;
+
+ // remove trailing slash if any
+ if (baseUrl.slice(-1) == '/')
+ baseUrl = baseUrl.substr(0, baseUrl.length - 1);
+ var url = baseUrl + "/Admin/Orchard.ContentPicker?";
+ url += "callback=" + callbackName + "&" + (new Date() - 0);
+ if ($("#" + editor.id).data("content-types")) {
+ url += "&types=" + $("#" + editor.id).data("content-types");
+ }
+ var w = window.open(url, "_blank", data.windowFeatures || "width=685,height=700,status=no,toolbar=no,location=no,menubar=no,resizable=no,scrollbars=yes");
+ }
+
+ // Add a button that opens a window
+ editor.addButton('orchardlink', {
+ image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsSAAALEgHS3X78AAABb0lEQVRIibWW223CQBBFDxEFUAIdJNHsf6CCkApiKgBXAFSAUgFJBdCB4X9HogSX4A6Sjx0rK8cGY5P7sw9Z93h3HvYAk4jbAk/cpgLYqPpz0wODCJDZ9NTSfBVBpk2QKuCk6tdt3EXcN5BGoFrIQ8u3bdIZeAZyIBNxf664LwBVnwPTJkhvgEGKJsiwp/dCxE2i9RFYAlsD9gIcgRHwUtkv4kVngKqf1u2LuHUMvUsMLunfAVevSMQtCUf+UvWHWwEXTyDidoSMGAF7EZfcDWDmCTC3gM6BnYgb9wZYoSSEXlP2l3LsDCiAQzTPgXd+KzMDzqr+2Amg6t+AmXXViUHGBs0MWJv7rQB25yszWpn5xsYjoR0XVYNrGkbmCSGQr4SsyYG8qWLbqjxBAqSq/hP4MNDYQL1UFloBPEbzPeEENxdWEyAl5PiIEOCcjndeVfxNngELM08NdOtfBlgnLWM3qHvC8n7bwbzUWdWnAD+rk38HDdeC5gAAAABJRU5ErkJggg==',
+ tooltip: 'Content link',
+ onclick: contentPickerAction
+ });
+
+ // Adds a menu item to the tools menu
+ editor.addMenuItem('orchardlink ', {
+ text: 'content link',
+ image: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsSAAALEgHS3X78AAABb0lEQVRIibWW223CQBBFDxEFUAIdJNHsf6CCkApiKgBXAFSAUgFJBdCB4X9HogSX4A6Sjx0rK8cGY5P7sw9Z93h3HvYAk4jbAk/cpgLYqPpz0wODCJDZ9NTSfBVBpk2QKuCk6tdt3EXcN5BGoFrIQ8u3bdIZeAZyIBNxf664LwBVnwPTJkhvgEGKJsiwp/dCxE2i9RFYAlsD9gIcgRHwUtkv4kVngKqf1u2LuHUMvUsMLunfAVevSMQtCUf+UvWHWwEXTyDidoSMGAF7EZfcDWDmCTC3gM6BnYgb9wZYoSSEXlP2l3LsDCiAQzTPgXd+KzMDzqr+2Amg6t+AmXXViUHGBs0MWJv7rQB25yszWpn5xsYjoR0XVYNrGkbmCSGQr4SsyYG8qWLbqjxBAqSq/hP4MNDYQL1UFloBPEbzPeEENxdWEyAl5PiIEOCcjndeVfxNngELM08NdOtfBlgnLWM3qHvC8n7bwbzUWdWnAD+rk38HDdeC5gAAAABJRU5ErkJggg==',
+ context: 'insert',
+ onclick: contentPickerAction
+ });
+
+ return {
+ getMetadata: function () {
+ return {
+ name: "Orchard content link plugin"
+ };
+ }
+ };
+});
diff --git a/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.min.js b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.min.js
new file mode 100644
index 000000000..f69818d12
--- /dev/null
+++ b/src/Orchard.Web/Modules/TinyMce/Scripts/plugins/orchardcontentlinks/plugin.min.js
@@ -0,0 +1 @@
+tinymce.PluginManager.add("orchardcontentlinks", function (A, n) { var t = function () { var n = {}, t = "_contentpicker_" + new Date().getTime(); n.callbackName = t, $[t] = function (n) { delete $[t]; var e = A.selection.getContent(); e && "" != e || (e = n.displayText), A.insertContent('' + e + "") }, $[t].data = n; var e = baseOrchardPath; "/" == e.slice(-1) && (e = e.substr(0, e.length - 1)); var g = e + "/Admin/Orchard.ContentPicker?"; g += "callback=" + t + "&" + (new Date - 0), $("#" + A.id).data("content-types") && (g += "&types=" + $("#" + A.id).data("content-types")), window.open(g, "_blank", n.windowFeatures || "width=685,height=700,status=no,toolbar=no,location=no,menubar=no,resizable=no,scrollbars=yes") }; return A.addButton("orchardlink", { image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsSAAALEgHS3X78AAABb0lEQVRIibWW223CQBBFDxEFUAIdJNHsf6CCkApiKgBXAFSAUgFJBdCB4X9HogSX4A6Sjx0rK8cGY5P7sw9Z93h3HvYAk4jbAk/cpgLYqPpz0wODCJDZ9NTSfBVBpk2QKuCk6tdt3EXcN5BGoFrIQ8u3bdIZeAZyIBNxf664LwBVnwPTJkhvgEGKJsiwp/dCxE2i9RFYAlsD9gIcgRHwUtkv4kVngKqf1u2LuHUMvUsMLunfAVevSMQtCUf+UvWHWwEXTyDidoSMGAF7EZfcDWDmCTC3gM6BnYgb9wZYoSSEXlP2l3LsDCiAQzTPgXd+KzMDzqr+2Amg6t+AmXXViUHGBs0MWJv7rQB25yszWpn5xsYjoR0XVYNrGkbmCSGQr4SsyYG8qWLbqjxBAqSq/hP4MNDYQL1UFloBPEbzPeEENxdWEyAl5PiIEOCcjndeVfxNngELM08NdOtfBlgnLWM3qHvC8n7bwbzUWdWnAD+rk38HDdeC5gAAAABJRU5ErkJggg==", tooltip: "Content link", onclick: t }), A.addMenuItem("orchardlink ", { text: "content link", image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsSAAALEgHS3X78AAABb0lEQVRIibWW223CQBBFDxEFUAIdJNHsf6CCkApiKgBXAFSAUgFJBdCB4X9HogSX4A6Sjx0rK8cGY5P7sw9Z93h3HvYAk4jbAk/cpgLYqPpz0wODCJDZ9NTSfBVBpk2QKuCk6tdt3EXcN5BGoFrIQ8u3bdIZeAZyIBNxf664LwBVnwPTJkhvgEGKJsiwp/dCxE2i9RFYAlsD9gIcgRHwUtkv4kVngKqf1u2LuHUMvUsMLunfAVevSMQtCUf+UvWHWwEXTyDidoSMGAF7EZfcDWDmCTC3gM6BnYgb9wZYoSSEXlP2l3LsDCiAQzTPgXd+KzMDzqr+2Amg6t+AmXXViUHGBs0MWJv7rQB25yszWpn5xsYjoR0XVYNrGkbmCSGQr4SsyYG8qWLbqjxBAqSq/hP4MNDYQL1UFloBPEbzPeEENxdWEyAl5PiIEOCcjndeVfxNngELM08NdOtfBlgnLWM3qHvC8n7bwbzUWdWnAD+rk38HDdeC5gAAAABJRU5ErkJggg==", context: "insert", onclick: t }), { getMetadata: function () { return { name: "Orchard content link plugin" } } } });
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/TinyMce/Settings/ContentLinksSettings.cs b/src/Orchard.Web/Modules/TinyMce/Settings/ContentLinksSettings.cs
new file mode 100644
index 000000000..13d97959c
--- /dev/null
+++ b/src/Orchard.Web/Modules/TinyMce/Settings/ContentLinksSettings.cs
@@ -0,0 +1,5 @@
+namespace TinyMce.Settings {
+ public class ContentLinksSettings {
+ public string DisplayedContentTypes { get; set; }
+ }
+}
diff --git a/src/Orchard.Web/Modules/TinyMce/Settings/EditorEvents.cs b/src/Orchard.Web/Modules/TinyMce/Settings/EditorEvents.cs
new file mode 100644
index 000000000..f27f69727
--- /dev/null
+++ b/src/Orchard.Web/Modules/TinyMce/Settings/EditorEvents.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Orchard.ContentManagement;
+using Orchard.ContentManagement.MetaData;
+using Orchard.ContentManagement.MetaData.Builders;
+using Orchard.ContentManagement.MetaData.Models;
+using Orchard.ContentManagement.ViewModels;
+using Orchard.Environment.Descriptor.Models;
+
+namespace TinyMce.Settings {
+ public class EditorEvents : ContentDefinitionEditorEventsBase {
+
+ private string[] _htmlParts = new string[] { "BodyPart", "LayoutPart" };
+ private string[] _htmlFields = new string[] { "TextField" };
+ private bool _contentLinksDependenciesEnabled = false;
+
+ public EditorEvents(ShellDescriptor shellDescriptor) {
+ var contenPickerEnabled = shellDescriptor.Features.Any(x => x.Name == "Orchard.ContentPicker") ? true : false;
+ var tokensHtmlFilterEnabled = shellDescriptor.Features.Any(x => x.Name == "Orchard.Tokens.HtmlFilter") ? true : false;
+ _contentLinksDependenciesEnabled = contenPickerEnabled && tokensHtmlFilterEnabled;
+ }
+
+ public override IEnumerable PartFieldEditor(ContentPartFieldDefinition definition) {
+ if (!_contentLinksDependenciesEnabled || !_htmlFields.Any(x => x.Equals(definition.FieldDefinition.Name, StringComparison.InvariantCultureIgnoreCase)))
+ yield break;
+ var model = definition.Settings.GetModel();
+ yield return DefinitionTemplate(model);
+ }
+
+ public override IEnumerable PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
+ if (!_contentLinksDependenciesEnabled || !_htmlFields.Any(x => x.Equals(builder.Name, StringComparison.InvariantCultureIgnoreCase)))
+ yield break;
+
+ var model = new ContentLinksSettings();
+ updateModel.TryUpdateModel(model, "ContentLinksSettings", null, null);
+ builder.WithSetting("ContentLinksSettings.DisplayedContentTypes", model.DisplayedContentTypes);
+
+ yield return DefinitionTemplate(model);
+ }
+
+ public override IEnumerable TypePartEditor(ContentTypePartDefinition definition) {
+ if (!_contentLinksDependenciesEnabled || !_htmlParts.Any(x => x.Equals(definition.PartDefinition.Name, StringComparison.InvariantCultureIgnoreCase)))
+ yield break;
+ var model = definition.Settings.GetModel();
+ yield return DefinitionTemplate(model);
+ }
+
+
+ public override IEnumerable TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
+ if (!_contentLinksDependenciesEnabled || !_htmlParts.Any(x => x.Equals(builder.Name, StringComparison.InvariantCultureIgnoreCase)))
+ yield break;
+ var model = new ContentLinksSettings();
+ updateModel.TryUpdateModel(model, "ContentLinksSettings", null, null);
+ builder.WithSetting("ContentLinksSettings.DisplayedContentTypes", model.DisplayedContentTypes);
+ yield return DefinitionTemplate(model);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard.Web/Modules/TinyMce/TinyMce.csproj b/src/Orchard.Web/Modules/TinyMce/TinyMce.csproj
index 2589e1a65..29ae701e7 100644
--- a/src/Orchard.Web/Modules/TinyMce/TinyMce.csproj
+++ b/src/Orchard.Web/Modules/TinyMce/TinyMce.csproj
@@ -250,6 +250,8 @@
+
+
@@ -317,6 +319,8 @@
+
+
@@ -379,7 +383,9 @@
+
+
10.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
diff --git a/src/Orchard.Web/Modules/TinyMce/Views/Body-Html.Editor.cshtml b/src/Orchard.Web/Modules/TinyMce/Views/Body-Html.Editor.cshtml
index 893554b37..862ed6fd6 100644
--- a/src/Orchard.Web/Modules/TinyMce/Views/Body-Html.Editor.cshtml
+++ b/src/Orchard.Web/Modules/TinyMce/Views/Body-Html.Editor.cshtml
@@ -3,17 +3,35 @@
@using Orchard.Environment.Descriptor.Models
@using Orchard.Localization
@using Orchard.Mvc.Extensions
+@using TinyMce.Settings;
@{
var shellDescriptor = WorkContext.Resolve();
var urlPrefix = WorkContext.Resolve().RequestUrlPrefix;
if (!string.IsNullOrWhiteSpace(urlPrefix)) {
urlPrefix += "/";
}
+ var contentTypes = "";
+ if (Model.Field != null) {
+ var settings = Model.Field.PartFieldDefinition.Settings.GetModel();
+ if (settings != null) {
+ contentTypes = settings.DisplayedContentTypes;
+ }
+ }
+ else if (Model.Part != null) {
+ var settings = Model.Part.TypePartDefinition.Settings.GetModel();
+ if (settings != null) {
+ contentTypes = settings.DisplayedContentTypes;
+ }
+ }
+
+
}