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

Clean up warnings in CKEditorProvider #4374

Merged
merged 1 commit into from Dec 21, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

@@ -1,21 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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

using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Script.Serialization;

using DNNConnect.CKEditorProvider.Objects;
using DNNConnect.CKEditorProvider.Utilities;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.FileSystem;

namespace DNNConnect.CKEditorProvider.Browser
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Script.Serialization;

using DNNConnect.CKEditorProvider.Objects;
using DNNConnect.CKEditorProvider.Utilities;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.FileSystem;

/// <summary>
/// The File Upload Handler.
Expand Down Expand Up @@ -211,10 +209,9 @@ private void UploadWholeFile(HttpContext context, List<FilesUploadStatus> status
}
}

var fileManager = FileManager.Instance;
var contentType = fileManager.GetContentType(Path.GetExtension(fileName));
var contentType = FileContentTypeManager.Instance.GetContentType(Path.GetExtension(fileName));
var userId = UserController.Instance.GetCurrentUserInfo().UserID;
fileManager.AddFile(this.StorageFolder, fileName, file.InputStream, this.OverrideFiles, true, contentType, userId);
FileManager.Instance.AddFile(this.StorageFolder, fileName, file.InputStream, this.OverrideFiles, true, contentType, userId);

var fullName = Path.GetFileName(fileName);
statuses.Add(new FilesUploadStatus(fullName, file.ContentLength));
Expand Down Expand Up @@ -244,4 +241,4 @@ private void WriteJsonIframeSafe(HttpContext context, List<FilesUploadStatus> st
context.Response.Write(jsonObj);
}
}
}
}
@@ -1,29 +1,24 @@
// 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

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;

using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;

namespace DNNConnect.CKEditorProvider.Browser
{
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web;

using DotNetNuke.Entities.Portals;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.FileSystem;

/// <summary>
/// The process image.
/// </summary>
public class ProcessImage : IHttpHandler
{
#region Properties

/// <summary>
/// Gets a value indicating whether IsReusable.
/// </summary>
Expand All @@ -35,10 +30,6 @@ public bool IsReusable
}
}

#endregion

#region Public Methods

/// <summary>
/// The get thumb abort.
/// </summary>
Expand All @@ -50,12 +41,6 @@ public bool GetThumbAbort()
return false;
}

#endregion

#region Implemented Interfaces

#region IHttpHandler

/// <summary>
/// The process request.
/// </summary>
Expand Down Expand Up @@ -102,7 +87,6 @@ public void ProcessRequest(HttpContext context)
if (file == null)
{
return;

}

Bitmap img = (Bitmap)Image.FromStream(FileManager.Instance.GetFileContent(file));
Expand Down Expand Up @@ -180,27 +164,15 @@ public void ProcessRequest(HttpContext context)
img.Dispose();
}

private bool HasWritePermission(string relativePath)
{
var portalId = PortalSettings.Current.PortalId;
return FolderPermissionController.HasFolderPermission(portalId, relativePath, "WRITE");
}

#endregion

#endregion

#region Methods

/// <summary>
/// Generats the New File Path.
/// Generates the New File Path.
/// </summary>
/// <param name="file">
/// The Original Image.
/// </param>
/// <param name="sNewFileName">
/// New File Name for the Image.
/// </param>
/// <param name="sSourceFullPath">
/// The Full Path of the Original Image.
/// </param>
/// <returns>
/// The generate name.
/// </returns>
Expand Down Expand Up @@ -290,11 +262,28 @@ private static Image RotateImage(Image img, double rotationAngle)
g.RotateTransform((float)rotationAngle);
g.TranslateTransform(-(float)img.Width / 2, -(float)img.Height / 2);

g.DrawImage(img, img.Width / 2 - img.Height / 2, img.Height / 2 - img.Width / 2, img.Height, img.Width);
g.DrawImage(img, (img.Width / 2) - (img.Height / 2), (img.Height / 2) - (img.Width / 2), img.Height, img.Width);

return returnBitmap;
}

private static string CleanName(string name)
{
name = name.Replace("\\", "/");
if (name.Contains("/"))
{
name = name.Substring(name.LastIndexOf('/') + 1);
}

return name;
}

private bool HasWritePermission(string relativePath)
{
var portalId = PortalSettings.Current.PortalId;
return FolderPermissionController.HasFolderPermission(portalId, relativePath, "WRITE");
}

/// <summary>
/// The resize image.
/// </summary>
Expand All @@ -315,18 +304,5 @@ private Bitmap ResizeImage(Image img, int width, int height)
Image.GetThumbnailImageAbort callback = this.GetThumbAbort;
return (Bitmap)img.GetThumbnailImage(width, height, callback, IntPtr.Zero);
}

private static string CleanName(string name)
{
name = name.Replace("\\", "/");
if (name.Contains("/"))
{
name = name.Substring(name.LastIndexOf('/') + 1);
}

return name;
}

#endregion
}
}
}