Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ck editor easy image #4405

Merged
merged 10 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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