Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Added Support for the Upload Image Plugin (resolves #25)
Browse files Browse the repository at this point in the history
  • Loading branch information
w8tcha committed Dec 25, 2017
1 parent ff1fa39 commit 3108d0f
Showing 88 changed files with 906 additions and 78 deletions.
19 changes: 18 additions & 1 deletion CKEditor/ckeditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/af.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/az.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/bg.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/bn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/bs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ca.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/cs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/cy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/da.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/de-ch.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/de.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/el.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/en-au.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/en-ca.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/en-gb.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/en.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/eo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/es-mx.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/es.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/et.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/eu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/fa.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/fi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/fo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/fr-ca.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/fr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/gl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/gu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/he.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/hi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/hr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/hu.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/id.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/is.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/it.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ja.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ka.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/km.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ko.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ku.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/lt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/lv.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/mk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/mn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ms.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/nb.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/nl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/no.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/oc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/pl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/pt-br.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/pt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ro.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ru.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/si.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sl.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sq.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sr-latn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/sv.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/th.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/tr.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/tt.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/ug.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/uk.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/vi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/zh-cn.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CKEditor/lang/zh.js

Large diffs are not rendered by default.

181 changes: 179 additions & 2 deletions DNN 7/Browser/Browser.aspx.cs
Original file line number Diff line number Diff line change
@@ -10,6 +10,8 @@
* this file is part of the Source Code of the CKEditor Provider.
*/

using System.Web.Script.Serialization;

namespace WatchersNET.CKEditor.Browser
{
#region
@@ -1043,15 +1045,25 @@ 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("ImageAutoUpload"))
{
return;
}

var uploadedFile =
HttpContext.Current.Request.Files[HttpContext.Current.Request.Files.AllKeys[0]];

if (uploadedFile != null)
if (uploadedFile == null)
{
return;
}

if (command.Equals("ImageAutoUpload"))
{
// Upload Auto Image Upload
this.UploadAutoImageFile(uploadedFile);
}
else
{
// Upload QuickFile
this.UploadQuickFile(uploadedFile, command);
@@ -2626,6 +2638,171 @@ private void ShowFilesIn(IFolderInfo currentFolderInfo, bool pagerChanged = fals
this.FilesList.DataBind();
}

/// <summary>
/// Automatically Uploads the Pasted Image
/// </summary>
/// <param name="file">
/// The Uploaded Image File
/// </param>
private void UploadAutoImageFile(HttpPostedFile file)
{
var fileName = Path.GetFileName(file.FileName).Trim();

if (!string.IsNullOrEmpty(fileName))
{
// Replace dots in the name with underscores (only one dot can be there... security issue).
fileName = Regex.Replace(fileName, @"\.(?![^.]*$)", "_", RegexOptions.None);

// Check for Illegal Chars
if (Utility.ValidateFileName(fileName))
{
fileName = Utility.CleanFileName(fileName);
}

// Convert Unicode Chars
fileName = Utility.ConvertUnicodeChars(fileName);
}
else
{
return;
}

// Check if file is to big for that user
if (this.currentSettings.UploadFileSizeLimit > 0
&& file.ContentLength > this.currentSettings.UploadFileSizeLimit)
{
var upload = new UploadImage
{
uploaded = 0,
fileName = string.Empty,
url = string.Empty,
error = new Error
{
message =
Localization.GetString("FileToBigMessage.Text", this.ResXFile, this.LanguageCode)
}
};

this.Response.ContentType = "application/json";
this.Response.ContentEncoding = Encoding.UTF8;

this.Response.Write(new JavaScriptSerializer().Serialize(upload));

HttpContext.Current.ApplicationInstance.CompleteRequest();

return;
}

if (fileName.Length > 220)
{
fileName = fileName.Substring(fileName.Length - 220);
}

var extension = Path.GetExtension(file.FileName);
extension = extension.TrimStart('.');

var allowUpload = this.allowedImageExtensions.Any(sAllowExt => sAllowExt.Equals(extension.ToLower()));

if (allowUpload)
{
var sFileNameNoExt = Path.GetFileNameWithoutExtension(fileName);

var counter = 0;

var uploadPhysicalPath = this.StartingDir().PhysicalPath;

var currentFolderInfo = Utility.ConvertFilePathToFolderInfo(
this.lblCurrentDir.Text,
this._portalSettings);

if (!this.currentSettings.UploadDirId.Equals(-1) && !this.currentSettings.SubDirs)
{
var uploadFolder = FolderManager.Instance.GetFolder(this.currentSettings.UploadDirId);

if (uploadFolder != null)
{
uploadPhysicalPath = uploadFolder.PhysicalPath;

currentFolderInfo = uploadFolder;
}
}

var sFilePath = Path.Combine(uploadPhysicalPath, fileName);

var imageResizer = new ImageResizer
{
ImageQuality = this.currentSettings.Config.ResizeImageQuality,
MaxHeight = this.currentSettings.Config.Resize_MaxHeight,
MaxWidth = this.currentSettings.Config.Resize_MaxWidth
};


// Automatically Resize Image on Upload
var fileStream =
this.currentSettings.Config.ResizeImageOnQuickUpload && Utility.IsImageFile(file.FileName)
? imageResizer.Resize(file)
: file.InputStream;

if (File.Exists(sFilePath))
{
counter++;
fileName = string.Format("{0}_{1}{2}", sFileNameNoExt, counter, Path.GetExtension(file.FileName));

FileManager.Instance.AddFile(currentFolderInfo, fileName, fileStream);
}
else
{
FileManager.Instance.AddFile(currentFolderInfo, fileName, fileStream);
}

var imageUrl = MapUrl(uploadPhysicalPath);

var upload = new UploadImage
{
uploaded = 1,
fileName = fileName,
url = string.Format(!imageUrl.EndsWith("/") ? "{0}/{1}" : "{0}{1}", imageUrl, fileName),
error = new Error
{
message =
string.Empty
}
};

this.Response.ContentType = "application/json";
this.Response.ContentEncoding = Encoding.UTF8;

this.Response.Write(new JavaScriptSerializer().Serialize(upload));

HttpContext.Current.ApplicationInstance.CompleteRequest();

this.Response.End();
}
else
{
var upload = new UploadImage
{
uploaded = 0,
fileName = string.Empty,
url = string.Empty,
error = new Error
{
message =
Localization.GetString("Error2.Text", this.ResXFile, this.LanguageCode)
}
};

this.Response.ContentType = "application/json";
this.Response.ContentEncoding = Encoding.UTF8;

this.Response.Write(new JavaScriptSerializer().Serialize(upload));

HttpContext.Current.ApplicationInstance.CompleteRequest();

this.Response.End();
}
}

/// <summary>
/// Uploads a File
/// </summary>
2 changes: 2 additions & 0 deletions DNN 7/Install/CKReleaseNotes.html
Original file line number Diff line number Diff line change
@@ -6,10 +6,12 @@
<title>CKEditor Provider Readme</title>
</head>
<body>
<h1>CKEditor 4.8.0 Editor Provider 2.01.12 <small>For DNN® Platform 07.04.02 (or above)</small></h1>
<h4>What's New</h4>
<div class="dnnFormMessage dnnFormSuccess">
<ul>
<li>Upgraded to CKEditor 4.8.0</li>
<li>Added Support for the Upload Image Plugin</li>
</ul>
</div>
<h5>changes</h5>
Binary file modified DNN 7/Install/bin/WatchersNET.CKEditor.dll
Binary file not shown.
39 changes: 39 additions & 0 deletions DNN 7/Objects/LinkItem - Kopieren.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* CKEditor Html Editor Provider for DNN
* ========
* https://github.com/w8tcha/dnnckeditor
* Copyright (C) Ingo Herbote
*
* The software, this file and its contents are subject to the CKEditor Provider
* License. Please read the license.txt file before using, installing, copying,
* modifying or distribute this file or part of its contents. The contents of
* this file is part of the Source Code of the CKEditor Provider.
*/

namespace WatchersNET.CKEditor.Objects
{
/// <summary>
/// A Link Item Class
/// </summary>
public class LinkItem
{
#region Properties

/// <summary>
/// Gets or sets Anchor.
/// </summary>
public string Anchor { get; set; }

/// <summary>
/// Gets or sets Href.
/// </summary>
public string Href { get; set; }

/// <summary>
/// Gets or sets Text.
/// </summary>
public string Text { get; set; }

#endregion
}
}
66 changes: 66 additions & 0 deletions DNN 7/Objects/UploadImage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* CKEditor Html Editor Provider for DNN
* ========
* https://github.com/w8tcha/dnnckeditor
* Copyright (C) Ingo Herbote
*
* The software, this file and its contents are subject to the CKEditor Provider
* License. Please read the license.txt file before using, installing, copying,
* modifying or distribute this file or part of its contents. The contents of
* this file is part of the Source Code of the CKEditor Provider.
*/

namespace WatchersNET.CKEditor.Objects
{
/// <summary>
/// The Upload Image Class
/// </summary>
public class UploadImage
{
/// <summary>
/// Gets or sets the uploaded.
/// </summary>
/// <value>
/// The uploaded.
/// </value>
public int uploaded { get; set; }

/// <summary>
/// Gets or sets the name of the file.
/// </summary>
/// <value>
/// The name of the file.
/// </value>
public string fileName { get; set; }

/// <summary>
/// Gets or sets the URL.
/// </summary>
/// <value>
/// The URL.
/// </value>
public string url { get; set; }

/// <summary>
/// Gets or sets the error.
/// </summary>
/// <value>
/// The error.
/// </value>
public Error error { get; set; }
}

/// <summary>
/// The Error Class
/// </summary>
public class Error
{
/// <summary>
/// Gets or sets the message.
/// </summary>
/// <value>
/// The message.
/// </value>
public string message { get; set; }
}
}
1 change: 1 addition & 0 deletions DNN 7/WatchersNET.CKEditor - DNN7.csproj
Original file line number Diff line number Diff line change
@@ -146,6 +146,7 @@
<Compile Include="Objects\ToolbarButton.cs" />
<Compile Include="Objects\ToolbarGroup.cs" />
<Compile Include="Objects\ToolbarSet.cs" />
<Compile Include="Objects\UploadImage.cs" />
<Compile Include="Objects\UploadSizeRoles.cs" />
<Compile Include="Objects\WordCountConfig.cs" />
<Compile Include="Tabs.ashx.cs">
12 changes: 12 additions & 0 deletions DNN 7/Web/CKEditorControl.cs
Original file line number Diff line number Diff line change
@@ -312,6 +312,8 @@ var info in
this._settings["language"] = "en";
}

this._settings["customConfig"] = string.Empty;

if (!string.IsNullOrEmpty(this.currentSettings.Config.Skin))
{
if (this.currentSettings.Config.Skin.Equals("office2003")
@@ -498,6 +500,16 @@ var info in
this.ID,
this.currentSettings.SettingMode,
CultureInfo.CurrentCulture.Name));
this._settings["imageUploadUrl"] =
Globals.ResolveUrl(
string.Format(
"~/Providers/HtmlEditorProviders/CKEditor/Browser/Browser.aspx?Command=ImageAutoUpload&tabid={0}&PortalID={1}&mid={2}&ckid={3}&mode={4}&lang={5}",
this._portalSettings.ActiveTab.TabID,
this._portalSettings.PortalId,
this.parentModulId,
this.ID,
this.currentSettings.SettingMode,
CultureInfo.CurrentCulture.Name));
}

this._settings["filebrowserWindowWidth"] = "870";
Loading

0 comments on commit 3108d0f

Please sign in to comment.