-
Notifications
You must be signed in to change notification settings - Fork 3
/
TinyMCERTEType.cs
86 lines (81 loc) · 2.85 KB
/
TinyMCERTEType.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.Diagnostics;
using Sitecore.Web.UI.WebControls.Ribbons;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Web;
using Sitecore;
namespace TinyMCERTE {
public class TinyMCERTEType : CustomField {
/// <summary>
/// Initializes a new instance of the <see cref="T:Sitecore.Data.Fields.TinyMCERTEType" /> class.
/// </summary>
/// <param name="innerField">The inner field.</param>
/// <contract>
/// <requires name="innerField" condition="none" />
/// </contract>
public TinyMCERTEType(Field innerField)
: base(innerField)
{
Assert.ArgumentNotNull((object)innerField, ExtensionMethods.nameof(() => innerField));
}
/// <summary>
/// Converts a <see cref="T:Sitecore.Data.Fields.Field" /> to a <see cref="T:Sitecore.Data.Fields.TinyMCERTEType" />.
/// </summary>
/// <param name="field">The field.</param>
/// <returns>The implicit operator.</returns>
public static implicit operator TinyMCERTEType(Field field)
{
if (field != null)
return new TinyMCERTEType(field);
return (TinyMCERTEType) null;
}
/// <summary>Gets the plain text.</summary>
/// <returns></returns>
public virtual string GetPlainText()
{
string input = this.InnerField.GetValue(true);
if (input == null)
return (string) null;
return HttpUtility.HtmlDecode(Regex.Replace(input, "<[^>]*>", string.Empty));
}
/// <summary>Gets the web edit buttons.</summary>
/// <returns>The web edit buttons.</returns>
/// <contract>
/// <ensures condition="nullable" />
/// </contract>
public override List<WebEditButton> GetWebEditButtons()
{
List<WebEditButton> webEditButtonList = new List<WebEditButton>();
Item obj = Sitecore.Client.GetDatabaseNotNull("core").GetItem(StringUtil.GetString(new string[2]
{
this.InnerField.Source,
Sitecore.Configuration.Settings.GetSetting("TinyEditor.DefaultProfile")
}));
if (obj == null)
return webEditButtonList;
Item child1 = obj.Children["WebEdit Buttons"];
if (child1 == null)
return webEditButtonList;
foreach (Item child2 in child1.Children)
{
WebEditButton webEditButton = new WebEditButton();
if (child2.TemplateID == Ribbon.Separator)
{
webEditButton.IsDivider = true;
}
else
{
webEditButton.Header = child2["Header"];
webEditButton.Icon = child2["Icon"];
webEditButton.Click = child2["Click"];
webEditButton.Tooltip = child2["Tooltip"];
}
if (UIUtil.SupportsInlineEditing() || webEditButton.Click.Contains("edithtml"))
webEditButtonList.Add(webEditButton);
}
return webEditButtonList;
}
}
}