Skip to content

Commit

Permalink
Merge pull request #12 from valadas/issue-11
Browse files Browse the repository at this point in the history
Replaced all deprecated API usages
  • Loading branch information
valadas authored Nov 9, 2018
2 parents 66323ff + 8794e3a commit 0a226a6
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 63 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ DNN [Pp]latform/Syndication/[Bb]in/*
![Ww]ebsite/[Ii]nstall/[Aa]pp_[Ll]ocal[Rr]esources/*.nl-NL.resx

*.zip.manifest
[Rr]esources.zip

############
## Windows
Expand Down
3 changes: 2 additions & 1 deletion Components/ExtensionObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using DotNetNuke.Common;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Framework;
using DotNetNuke.Web.Client.ClientResourceManagement;

namespace DotNetNuke.Modules.Xml.Components
{
Expand Down Expand Up @@ -79,7 +80,7 @@ public void registerStyleSheet(string href)
{
if ((_page != null) && (_page) is CDefault)
{
((CDefault) _page).AddStyleSheet(Globals.CreateValidID(href), href);
ClientResourceManager.RegisterStyleSheet(_page, href);
}
}

Expand Down
73 changes: 40 additions & 33 deletions Components/FeatureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Portals;
using DotNetNuke.Modules.Xml.Providers.XmlDataProvider;
using DotNetNuke.Modules.Xml.Providers.XmlRenderingProvider;
using DotNetNuke.Services.Search;
using DotNetNuke.Services.Search.Entities;
using DotNetNuke.Services.Search.Internals;

namespace DotNetNuke.Modules.Xml.Components
{
Expand All @@ -34,16 +38,48 @@ namespace DotNetNuke.Modules.Xml.Components
/// The Controller class for Xml Module
/// </summary>
/// -----------------------------------------------------------------------------
public class FeatureController : IPortable, ISearchable
public class FeatureController : ModuleSearchBase, IPortable
{
#region ModuleSearchBase Implementation
public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
{
var controller = new XmlBaseController(moduleInfo);
var portalId = moduleInfo.PortalID;
var administratorId = PortalController.Instance.GetPortal(portalId).AdministratorId;

var searchDocuments = new List<SearchDocument>();
InternalSearchController.Instance.DeleteSearchDocumentsByModule(portalId, moduleInfo.ModuleID, moduleInfo.ModuleDefID);
if (MustAddContentToSearch(moduleInfo))
{
var sw = new StringWriter();
controller.Render(sw);
sw.Flush();
var content = sw.ToString();
var now = DateTime.Now;

var searchDoc = new SearchDocument();
searchDoc.Title = moduleInfo.ModuleTitle;
searchDoc.Description = content;
searchDoc.AuthorUserId = administratorId;
searchDoc.ModifiedTimeUtc = now;
searchDoc.ModuleId = moduleInfo.ModuleID;
searchDoc.Body = content;

searchDocuments.Add(searchDoc);
}
return searchDocuments;
}
#endregion

#region IPortable Members

/// <summary>
/// IPortable: Export
/// </summary>
public string ExportModule(int moduleId)
{
var settings = new ModuleController().GetModuleSettings(moduleId);
var moduleInfo = ModuleController.Instance.GetModule(moduleId, Null.NullInteger, false);
var settings = moduleInfo.ModuleSettings;
//start export
var strXml = new StringWriter();
XmlWriter writer = new XmlTextWriter(strXml);
Expand Down Expand Up @@ -106,36 +142,7 @@ public void ImportModule(int moduleId, string content, string version, int userI
}

#endregion

#region ISearchable Members

///<summary>
/// DotNetNuke Search support
///</summary>
public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo)
{
var controller = new XmlBaseController(modInfo);

var portalId = modInfo.PortalID;
var administratorId = new PortalController().GetPortal(portalId).AdministratorId;

var searchItemCollection = new SearchItemInfoCollection();
if (MustAddContentToSearch(modInfo))
{
var sw = new StringWriter();
controller.Render(sw);
sw.Flush();
var content = sw.ToString();
var now = DateTime.Now;
searchItemCollection.Add(new SearchItemInfo(modInfo.ModuleTitle, content, administratorId, now, modInfo.ModuleID, "", content));
var mc = new ModuleController();
mc.UpdateModuleSetting(modInfo.ModuleID, Setting.LastIndexRun, DateTime.Now.ToString("s"));
}
return searchItemCollection;
}

#endregion


/// <summary>
/// Determines whether the module should be indexed or not.
/// </summary>
Expand All @@ -160,6 +167,6 @@ private static bool MustAddContentToSearch(ModuleInfo modInfo)
default:
return false;
}
}
}
}
}
14 changes: 9 additions & 5 deletions Components/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Net;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Xml;
using DotNetNuke.Common.Utilities;
Expand Down Expand Up @@ -57,7 +58,9 @@ public static string DefaultIfNullOrEmpty(this object value, string @default = "
/// </remarks>
public static bool CheckWebPermission(string url)
{
return SecurityManager.IsGranted(new WebPermission(NetworkAccess.Connect, url));
var permissionSet = new PermissionSet(System.Security.Permissions.PermissionState.None);
permissionSet.AddPermission(new WebPermission(NetworkAccess.Connect, url));
return permissionSet.IsSubsetOf(AppDomain.CurrentDomain.PermissionSet);
}

public static bool IsOfSameTypeAs(this object a, object b)
Expand All @@ -69,10 +72,11 @@ public static bool IsOfSameTypeAs(this object a, object b)

public static XmlReader CreateXmlReader(string xmlsrc, int portalId, bool prohibitDtd)
{
if (xmlsrc == String.Empty) return null;
var filecontroller = new FileController();
var xmlFileInfo = filecontroller.GetFileById(filecontroller.ConvertFilePathToFileId(xmlsrc, portalId), portalId);
return XmlReader.Create(FileSystemUtils.GetFileStream(xmlFileInfo), new XmlReaderSettings {ProhibitDtd = prohibitDtd});
if (xmlsrc == String.Empty) return null;
var xmlFileInfo = FileManager.Instance.GetFile(portalId, xmlsrc, true);
var xmlSettings = new XmlReaderSettings();
xmlSettings.DtdProcessing = DtdProcessing.Prohibit;
return XmlReader.Create(FileManager.Instance.GetFileContent(xmlFileInfo), xmlSettings);
}

public static XmlReader CreateXmlReader(string xmlsrc, int portalId)
Expand Down
10 changes: 3 additions & 7 deletions Components/XmlBaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Web;
using System.Web.UI;
using System.Xml;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Data;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Modules.Xml.Providers.XmlDataProvider;
Expand Down Expand Up @@ -130,13 +131,8 @@ public void Render(Stream stream)
/// </summary>
public void ClearSearchIndex()
{
// FIX: for Error CS1061 'DataProvider' does not contain a definition for 'DeleteSearchItems' and no extension method 'DeleteSearchItems' accepting a first argument of type 'DataProvider' could be found(are you missing a using directive or an assembly reference ?) Xml D:\Materijali\SD\Portal2015\Dev\Prototips\DNN.XML\Components\XmlBaseController.cs 132 Active
//DataProvider.Instance().DeleteSearchItems(ModuleId);
var moduleSearchItems = SearchDataStoreController.GetSearchItems(ModuleId);
foreach (var searchItem in moduleSearchItems)
{
SearchDataStoreController.DeleteSearchItem(searchItem.Value.SearchItemId);
}
var moduleInfo = ModuleController.Instance.GetModule(ModuleId, Null.NullInteger, true);
DotNetNuke.Services.Search.Internals.InternalSearchController.Instance.DeleteSearchDocumentsByModule(moduleInfo.PortalID, ModuleId, moduleInfo.ModuleDefID);
}


Expand Down
7 changes: 6 additions & 1 deletion DNN_XML.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<OutputPath>..\..\bin\</OutputPath>
<DocumentationFile>Xml.xml</DocumentationFile>
<WarningLevel>1</WarningLevel>
<WarningLevel>2</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
Expand All @@ -56,6 +56,11 @@
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="DotNetNuke.Web.Client, Version=8.0.1.239, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\DotNetNuke.Web.Client.8.0.1.239\lib\net40\DotNetNuke.Web.Client.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="DotNetNuke.WebUtility, Version=4.2.1.783, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\DotNetNuke.Web.8.0.0.809\lib\net40\DotNetNuke.WebUtility.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
Expand Down
4 changes: 2 additions & 2 deletions Parameters/ParameterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public string GetValue()
default:
// user property
// get current user
var objUser = UserController.GetCurrentUserInfo();
var objUser = UserController.Instance.GetCurrentUserInfo();

// handle user property
switch (ParseType(Type))
Expand Down Expand Up @@ -361,7 +361,7 @@ public string GetValue()
return objUser.Profile.PreferredLocale.DefaultIfNullOrEmpty(TypeArgument);
case ParameterType.UserTimeZone:

return objUser.Profile.TimeZone.DefaultIfNullOrEmpty(TypeArgument);
return objUser.Profile.PreferredTimeZone.DefaultIfNullOrEmpty(TypeArgument);
case ParameterType.UserIsAuthorized:

return objUser.Membership.Approved.DefaultIfNullOrEmpty(TypeArgument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ private static System.Xml.Xsl.XslCompiledTransform GetXslContentByWebRequest(str
{
if (receiveStream != null)
{
using (var objXslTransform = XmlReader.Create(receiveStream, new XmlReaderSettings {ProhibitDtd = prohibitDtd}))
var xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.DtdProcessing = DtdProcessing.Prohibit;
using (var objXslTransform = XmlReader.Create(receiveStream, xmlReaderSettings ))
{
var settings = new XsltSettings(enableDocument, enableScript);
xslCompiledTransform.Load(objXslTransform, settings, new XmlUrlResolver());
Expand Down
Binary file removed Resources.zip
Binary file not shown.
5 changes: 0 additions & 5 deletions Xml.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions download.ashx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void ProcessRequest(HttpContext context)
{
try
{
var portalSettings = PortalController.GetCurrentPortalSettings();
var portalSettings = PortalController.Instance.GetCurrentPortalSettings();

if (context.Request.QueryString["tabid"] == null || context.Request.QueryString["mid"] == null)
return;
Expand All @@ -94,11 +94,10 @@ public void ProcessRequest(HttpContext context)
moduleId = Int32.Parse(context.Request.QueryString["mid"]);
}

UserController.GetCurrentUserInfo();

var moduleController = new ModuleController();
var settings = moduleController.GetModuleSettings(moduleId);
var moduleInfo = moduleController.GetModule(moduleId, tabId);
UserController.Instance.GetCurrentUserInfo();

var moduleInfo = ModuleController.Instance.GetModule(moduleId, tabId, false);
var settings = moduleInfo.ModuleSettings;

if (context.Request.QueryString["showsource"] == null)
{
Expand All @@ -115,7 +114,7 @@ public void ProcessRequest(HttpContext context)
}
}
}
catch (Exception ex)
catch (Exception)
{
context.Response.Write("Not defined");
}
Expand Down
1 change: 1 addition & 0 deletions packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<packages>
<package id="DotNetNuke.Core" version="8.0.0.809" targetFramework="net45" />
<package id="DotNetNuke.Web" version="8.0.0.809" targetFramework="net45" />
<package id="DotNetNuke.Web.Client" version="8.0.1.239" targetFramework="net45" />
<package id="MSBuildTasks" version="1.5.0.235" targetFramework="net45" developmentDependency="true" />
</packages>
3 changes: 2 additions & 1 deletion releasenotes.htm
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<h4>Release Notes</h4>
<h2>DNN XML Module 06.00.06 </h2>
<p>This release is compiled against the .Net 4.5 Framework using VS2015.<br />The minimum DNNPlatform version is 8.0.0 </p>
<p>This release is compiled against the .Net 4.5 Framework using VS2015.<br />The minimum DNNPlatform version is 8.0.0 and this module has been teste up to Dnn 9.3.0</p>
<h4>06.00.05</h4>
<ul>
<li>Source code dependencies are now pulled from Nuget</li>
<li>Replaced all deprecated API usages for Dnn 9.2 and up compatibility</li>
</ul>
<h4>06.00.04</h4>
<ul>
Expand Down

0 comments on commit 0a226a6

Please sign in to comment.