Skip to content

Commit

Permalink
Finalizing implementation of EasyImage Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
skamphuis committed Jan 8, 2021
1 parent 2644b61 commit 3d52bd1
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 187 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ protected void Page_Load(object sender, EventArgs e)
this.portalSettings,
HttpContext.Current.Request);

if ((this.currentSettings.BrowserMode.Equals(BrowserType.StandardBrowser) || !this.currentSettings.ImageButtonMode.Equals(ImageButtonType.None))
if ((this.currentSettings.BrowserMode.Equals(BrowserType.StandardBrowser) || this.currentSettings.ImageButtonMode.Equals(ImageButtonType.EasyImageButton))
&& HttpContext.Current.Request.IsAuthenticated)
{
string command = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@
<div class="dnnFormItem">
<asp:label id="lblImageButton" runat="server" CssClass="dnnLabel">Image Button:</asp:label>
<asp:dropdownlist id="ddlImageButton" runat="server" CssClass="DefaultDropDown">
<asp:ListItem Text="None" Value="none" Enabled="true"></asp:ListItem>
<asp:ListItem Text="Standard" Value="standard" ></asp:ListItem>
<asp:ListItem Text="Easy Image" Value="easyimage"></asp:ListItem>
<asp:ListItem Text="Easy Image Upload" Value="easyimage"></asp:ListItem>
</asp:dropdownlist>
</div>
<div class="dnnFormItem">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ namespace DNNConnect.CKEditorProvider.Constants
/// </summary>
public enum ImageButtonType
{
/// <summary>
/// The none button.
/// </summary>
None = 0,

/// <summary>
/// The standard button.
/// </summary>
StandardBrowser = 1,
StandardButton = 1,

/// <summary>
/// easy image button
/// </summary>
EasyImage = 2,
EasyImageButton = 2,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<Compile Include="Objects\UploadSizeRoles.cs" />
<Compile Include="Objects\WordCountConfig.cs" />
<Compile Include="Services\CKEditorProviderRouteMapper.cs" />
<Compile Include="Services\EasyImageController.cs" />
<Compile Include="Services\CloudServicesController.cs" />
<Compile Include="Tabs.ashx.cs">
<DependentUpon>Tabs.ashx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DNNConnect.CKEditorProvider.Services
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;

using DotNetNuke.Common;
using DotNetNuke.Services.Installer.Log;
using DotNetNuke.Web.Api;
using DotNetNuke.Web.Api.Internal;

/// <summary>
/// WebAPI controller to enable the CKE cloudservices plugin.
/// </summary>
public class CloudServicesController : DnnApiController
{
/// <summary>
/// Provides a dummy token the cloudservices plugin needs.
/// </summary>
/// <returns>A dummy token.</returns>
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage GetToken()
{
return this.Request.CreateResponse(HttpStatusCode.OK, "dummytoken");
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -472,40 +472,21 @@ internal static EditorProviderSettings LoadEditorSettingsByKey(
{
currentSettings.ImageButton = settingValue;

switch (currentSettings.ImageButton)
if (currentSettings.ImageButton == "easyimage")
{
case "easyimage":
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
currentSettings.ImageButtonMode = ImageButtonType.EasyImage;

break;
}

currentSettings.ImageButtonMode = ImageButtonType.None;
}

break;
case "standard":
foreach (string sRoleName in roles)
currentSettings.ImageButtonMode = ImageButtonType.StandardButton;
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
if (PortalSecurity.IsInRoles(sRoleName))
{
currentSettings.ImageButtonMode = ImageButtonType.StandardBrowser;

break;
}

currentSettings.ImageButtonMode = ImageButtonType.None;
currentSettings.ImageButtonMode = ImageButtonType.EasyImageButton;
}

break;
case "none":
currentSettings.ImageButtonMode = ImageButtonType.None;
break;
}
}
else
{
currentSettings.ImageButtonMode = ImageButtonType.StandardButton;
}
}
}

Expand Down Expand Up @@ -1111,39 +1092,20 @@ PropertyInfo info in
{
currentSettings.ImageButton = (string)hshModSet[string.Format("{0}{1}", key, SettingConstants.IMAGEBUTTON)];

switch (currentSettings.ImageButton)
if (currentSettings.ImageButton == "easyimage")
{
case "easyimage":
foreach (string sRoleName in roles)
currentSettings.ImageButtonMode = ImageButtonType.StandardButton;
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
if (PortalSecurity.IsInRoles(sRoleName))
{
currentSettings.ImageButtonMode = ImageButtonType.EasyImage;

break;
}

currentSettings.ImageButtonMode = ImageButtonType.None;
currentSettings.ImageButtonMode = ImageButtonType.EasyImageButton;
}

break;
case "standard":
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
currentSettings.ImageButtonMode = ImageButtonType.StandardBrowser;

break;
}

currentSettings.ImageButtonMode = ImageButtonType.None;
}

break;
case "none":
currentSettings.ImageButtonMode = ImageButtonType.None;
break;
}
}
else
{
currentSettings.ImageButtonMode = ImageButtonType.StandardButton;
}
}

Expand Down Expand Up @@ -1429,39 +1391,20 @@ internal static EditorProviderSettings GetDefaultSettings(IPortalSettings portal

if (!string.IsNullOrEmpty(settings.ImageButton))
{
switch (settings.ImageButton)
if (settings.ImageButton == "easyimage")
{
case "easyimage":
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
settings.ImageButtonMode = ImageButtonType.EasyImage;

break;
}

settings.ImageButtonMode = ImageButtonType.None;
}

break;
case "standard":
foreach (string sRoleName in roles)
settings.ImageButtonMode = ImageButtonType.StandardButton;
foreach (string sRoleName in roles)
{
if (PortalSecurity.IsInRoles(sRoleName))
{
if (PortalSecurity.IsInRoles(sRoleName))
{
settings.ImageButtonMode = ImageButtonType.StandardBrowser;

break;
}

settings.ImageButtonMode = ImageButtonType.None;
settings.ImageButtonMode = ImageButtonType.EasyImageButton;
}

break;
case "none":
settings.ImageButtonMode = ImageButtonType.None;
break;
}
}
else
{
settings.ImageButtonMode = ImageButtonType.StandardButton;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ PropertyInfo info in
}

// Easy Image Upload
if (this.currentSettings.ImageButtonMode == ImageButtonType.EasyImage)
if (this.currentSettings.ImageButtonMode == ImageButtonType.EasyImageButton)
{
// replace 'Image' Plugin with 'EasyImage'
this.settings["toolbar"] = this.settings["toolbar"].Replace("'Image'", "'EasyImageUpload'");
Expand All @@ -387,6 +387,9 @@ PropertyInfo info in
this.settings["extraPlugins"] += "easyimage";
}

// change the easyimage toolbar
this.settings["easyimage_toolbar"] = "['EasyImageAlt']";

// remove the image plugin in removePlugins
if (string.IsNullOrEmpty(this.settings["removePlugins"]) || !this.settings["removePlugins"].Split(',').Contains("image"))
{
Expand All @@ -410,37 +413,20 @@ PropertyInfo info in
}
else
{
if (this.currentSettings.ImageButtonMode == ImageButtonType.StandardBrowser)
// remove the easyimage plugin in removePlugins
if (string.IsNullOrEmpty(this.settings["removePlugins"]) || !this.settings["removePlugins"].Split(',').Contains("easyimage"))
{
// remove the easyimage plugin in removePlugins
if (string.IsNullOrEmpty(this.settings["removePlugins"]) || !this.settings["removePlugins"].Split(',').Contains("easyimage"))
if (!string.IsNullOrEmpty(this.settings["removePlugins"]))
{
if (!string.IsNullOrEmpty(this.settings["removePlugins"]))
{
this.settings["removePlugins"] += ",";
}

this.settings["removePlugins"] += "easyimage";
this.settings["removePlugins"] += ",";
}
}

if (this.currentSettings.ImageButtonMode == ImageButtonType.None)
{
// remove the image plugin in removePlugins
if (string.IsNullOrEmpty(this.settings["removePlugins"]) || !this.settings["removePlugins"].Split(',').Contains("image"))
{
if (!string.IsNullOrEmpty(this.settings["removePlugins"]))
{
this.settings["removePlugins"] += ",";
}

this.settings["removePlugins"] += "image";
}
this.settings["removePlugins"] += "easyimage";
}
}

// cloudservices variables need to be set regardless
this.settings.Add("cloudServices_tokenUrl", "/API/CKEditorProvider/EasyImage/GetToken");
this.settings.Add("cloudServices_tokenUrl", "/API/CKEditorProvider/CloudServices/GetToken");

// Editor Width
if (!string.IsNullOrEmpty(this.currentSettings.Config.Width))
Expand Down Expand Up @@ -1058,13 +1044,10 @@ private void CheckImageButton()
switch (objProvider.Attributes["ck_imagebutton"])
{
case "easyimage":
this.currentSettings.ImageButtonMode = ImageButtonType.EasyImage;
this.currentSettings.ImageButtonMode = ImageButtonType.EasyImageButton;
break;
case "standard":
this.currentSettings.ImageButtonMode = ImageButtonType.StandardBrowser;
break;
case "none":
this.currentSettings.ImageButtonMode = ImageButtonType.None;
this.currentSettings.ImageButtonMode = ImageButtonType.StandardButton;
break;
}
}
Expand Down

0 comments on commit 3d52bd1

Please sign in to comment.