Skip to content

Commit

Permalink
Feature/ck editor easy image (#4405)
Browse files Browse the repository at this point in the history
* CKE 4.15.1 with EasyImage plugin

* added webapi

* added useSimpleImageUpload setting

* implementing easyImageUpload

* no cloudservice-url for normal dialog

* still duplicate post request

* working

* Working with setting "Image Button"

* Finalizing implementation of EasyImage Plugin

* EasyImage - cleanup dev leftovers
  • Loading branch information
skamphuis committed Jan 19, 2021
1 parent 3521b0a commit e2bc7a6
Show file tree
Hide file tree
Showing 111 changed files with 1,707 additions and 208 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@ protected virtual string GetJsUploadCode(string fileName, string fileUrl)
var httpRequest = HttpContext.Current.Request;

// var _CKEditorName = request.QueryString["CKEditor"];
// funcNum is null when EasyImageUpload is being used
var funcNum = httpRequest.QueryString["CKEditorFuncNum"];

var errorMsg = string.Empty;
Expand Down Expand Up @@ -932,7 +933,7 @@ protected void Page_Load(object sender, EventArgs e)
this.portalSettings,
HttpContext.Current.Request);

if (this.currentSettings.BrowserMode.Equals(BrowserType.StandardBrowser)
if ((this.currentSettings.BrowserMode.Equals(BrowserType.StandardBrowser) || this.currentSettings.ImageButtonMode.Equals(ImageButtonType.EasyImageButton))
&& HttpContext.Current.Request.IsAuthenticated)
{
string command = null;
Expand Down Expand Up @@ -1032,7 +1033,7 @@ protected void Page_Load(object sender, EventArgs e)
if (command != null)
{
if (!command.Equals("FileUpload") && !command.Equals("FlashUpload")
&& !command.Equals("ImageUpload"))
&& !command.Equals("ImageUpload") && !command.Equals("EasyImageUpload"))
{
return;
}
Expand Down Expand Up @@ -2428,6 +2429,7 @@ private void UploadFile(HttpPostedFile file, string command)
}

break;
case "EasyImageUpload":
case "ImageUpload":
if (AllowedImageExtensions.Contains(sExtension))
{
Expand Down Expand Up @@ -2480,9 +2482,20 @@ private void UploadFile(HttpPostedFile file, string command)
FileManager.Instance.AddFile(currentFolderInfo, fileName, file.InputStream);
}

this.Response.Write("<script type=\"text/javascript\">");
this.Response.Write(this.GetJsUploadCode(fileName, MapUrl(uploadPhysicalPath)));
this.Response.Write("</script>");
if (command == "EasyImageUpload")
{
var fileUrl = string.Format(!MapUrl(uploadPhysicalPath).EndsWith("/") ? "{0}/{1}" : "{0}{1}", MapUrl(uploadPhysicalPath), fileName);
this.Response.ClearContent();
this.Response.ContentType = "application/json";
this.Response.Write($"{{\"default\": \"{fileUrl}\"}}");
}
else
{
this.Response.Write("<script type=\"text/javascript\">");
this.Response.Write(this.GetJsUploadCode(fileName, MapUrl(uploadPhysicalPath)));
this.Response.Write("</script>");
}

this.Response.End();
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
<asp:ListItem Text="None" Value="none" Enabled="true"></asp:ListItem>
<asp:ListItem Text="Standard" Value="standard" ></asp:ListItem>
<asp:ListItem Text="CKFinder" Value="ckfinder"></asp:ListItem>
</asp:dropdownlist>
</div>
<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="Standard" Value="standard" ></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 @@ -795,6 +795,13 @@ var codeMirrorInfo in
this.ddlBrowser.SelectedValue = importedSettings.Browser;
}

if (!string.IsNullOrEmpty(importedSettings.ImageButton)
&& this.ddlImageButton.Items.FindByValue(importedSettings.ImageButton) != null)
{
this.ddlImageButton.ClearSelection();
this.ddlImageButton.SelectedValue = importedSettings.ImageButton;
}

this.FileListPageSize.Text = importedSettings.FileListPageSize.ToString();

this.FileListViewMode.SelectedValue = importedSettings.FileListViewMode.ToString();
Expand Down Expand Up @@ -1820,6 +1827,12 @@ private void LoadDefaultSettings()
this.ddlBrowser.SelectedValue = ckeditorProvider.Attributes["ck_Browser"];
}

// ImageButton
if (ckeditorProvider.Attributes["ck_ImageButton"] != string.Empty)
{
this.ddlImageButton.SelectedValue = ckeditorProvider.Attributes["ck_ImageButton"];
}

if (ckeditorProvider.Attributes["ck_contentsCss"] != string.Empty)
{
this.CssUrl.Url = ckeditorProvider.Attributes["ck_contentsCss"];
Expand Down Expand Up @@ -2427,6 +2440,7 @@ var codeMirrorInfo in
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.SKIN}", this.ddlSkin.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.CODEMIRRORTHEME}", this.CodeMirrorTheme.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.BROWSER}", this.ddlBrowser.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.IMAGEBUTTON}", this.ddlImageButton.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.FILELISTVIEWMODE}", this.FileListViewMode.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.DEFAULTLINKMODE}", this.DefaultLinkMode.SelectedValue);
moduleController.UpdateModuleSetting(this.ModuleId, $"{key}{SettingConstants.USEANCHORSELECTOR}", this.UseAnchorSelector.Checked.ToString());
Expand Down Expand Up @@ -2680,6 +2694,7 @@ private void SaveSettingsByKey(string key)
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.SKIN}", this.ddlSkin.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.CODEMIRRORTHEME}", this.CodeMirrorTheme.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.BROWSER}", this.ddlBrowser.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.IMAGEBUTTON}", this.ddlImageButton.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.FILELISTVIEWMODE}", this.FileListViewMode.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.DEFAULTLINKMODE}", this.DefaultLinkMode.SelectedValue);
EditorController.AddOrUpdateEditorHostSetting($"{key}{SettingConstants.USEANCHORSELECTOR}", this.UseAnchorSelector.Checked.ToString());
Expand Down Expand Up @@ -3314,6 +3329,7 @@ private EditorProviderSettings ExportSettings()
exportSettings.Config.Skin = this.ddlSkin.SelectedValue;
exportSettings.Config.CodeMirror.Theme = this.CodeMirrorTheme.SelectedValue;
exportSettings.Browser = this.ddlBrowser.SelectedValue;
exportSettings.ImageButton = this.ddlImageButton.SelectedValue;
exportSettings.FileListViewMode =
(FileListView)Enum.Parse(typeof(FileListView), this.FileListViewMode.SelectedValue);
exportSettings.DefaultLinkMode = (LinkMode)Enum.Parse(typeof(LinkMode), this.DefaultLinkMode.SelectedValue);
Expand Down
Loading

0 comments on commit e2bc7a6

Please sign in to comment.