Skip to content

Commit

Permalink
Merge pull request #19 from valadas/Issue15
Browse files Browse the repository at this point in the history
Total rewrite in WAP C#, build process, Dnn9.2 compatible, closes #15
  • Loading branch information
valadas authored Jun 29, 2018
2 parents 0033030 + c35d7d0 commit 86d96c8
Show file tree
Hide file tree
Showing 46 changed files with 4,444 additions and 3,715 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
.builds
*.dotCover
*.ldf
[Bb]in

# git merge artifacts
*.orig
Expand Down
13 changes: 13 additions & 0 deletions AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: System.Reflection.AssemblyVersion("7.0.0.00")]


186 changes: 186 additions & 0 deletions BuildScripts/ModulePackage.Targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- WARING, IF YOU EDIT THE TARGETS FILE YOU NEED TO CLOSE/OPEN YOUR THE PROJECT FOR THE CHANGES TO TAKE EFFECT -->

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<CompanyName>DotNetNuke</CompanyName>
<ModuleName>Links</ModuleName>
<ModuleIconFile>img\links-icon.png</ModuleIconFile>
<DotNetNukeDir>..\..\</DotNetNukeDir>
<DeployModuleFolder>$(DotNetNukeDir)DesktopModules\Links</DeployModuleFolder>
<InstallDir>$(MSBuildProjectDirectory)\Install</InstallDir>
<BinDir>$(DotNetNukeDir)\bin</BinDir>
</PropertyGroup>





<Target Name="PackageModule">
<CallTarget Targets="DeployModule" Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
<CallTarget Targets="CreateInstallPackages" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
</Target>

<Target Name="DeleteTempFiles">
<RemoveDir Directories ="$(MSBuildProjectDirectory)\Package" />
<RemoveDir Directories ="$(MSBuildProjectDirectory)\ResourcesZip" />
<ItemGroup>
<CleanupInclude Include="DNN_$(ModuleName)_*_Install.zip" Exclude="Install\**" />
<CleanupInclude Include="DNN_$(ModuleName)_*_Source.zip" Exclude="Install\**" />
</ItemGroup>
<Delete Files="@(CleanupInclude)" />
<Delete Files="$(MSBuildProjectDirectory)\Resources.zip" />
</Target>

<Target Name="DeployModule">
<!-- <Delete Files="$(MSBuildProjectDirectory)\DebugDeploy.zip" /> -->

<!-- Assemblies -->
<ItemGroup>
<DebugAssemblies Include="$(MSBuildProjectDirectory)\bin\*.dll;$(MSBuildProjectDirectory)\bin\*.pdb" />
</ItemGroup>
<Copy SourceFiles="@(DebugAssemblies)" DestinationFolder="$(BinDir)" SkipUnchangedFiles="true" ContinueOnError="true" />

<!-- Copy other files to deploy folder -->
<ItemGroup>
<DeployInclude Include="**\*.ascx" />
<DeployInclude Include="**\*.asmx" />
<DeployInclude Include="**\*.css" />
<DeployInclude Include="**\*.xsl" />
<DeployInclude Include="**\*.html" />
<DeployInclude Include="**\*.htm" />
<DeployInclude Include="**\*.resx" />
<DeployInclude Include="**\*.xml" Exclude="**\obj\**;**\_ReSharper*\**;**\.git\**;**\packages\**" />
<DeployInclude Include="**\*.aspx" />
<DeployInclude Include="**\*.js" />
<DeployInclude Include="**\*.txt" Exclude="**\obj\**;**\_ReSharper*\**;**\.git\**;" />
<DeployInclude Include="**\images\**" />
<DeployInclude Include="**\img\**" Exclude="packages\**" />
</ItemGroup>
<Zip Files="@(DeployInclude)" ZipFileName="$(MSBuildProjectDirectory)\DebugDeploy.zip"
WorkingDirectory="$(MSBuildProjectDirectory)" />
<Unzip ZipFileName="$(MSBuildProjectDirectory)\DebugDeploy.zip" TargetDirectory="$(DeployModuleFolder)" />
<Delete Files="$(MSBuildProjectDirectory)\DebugDeploy.zip" />
</Target>

<Target Name="CreateInstallPackages">

<!-- Set the module version -->
<XmlRead Prefix="n" Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="dotnetnuke/packages/package[1]/@version"
XmlFileName="$(MSBuildProjectDirectory)\DNN_Links.dnn">
<Output TaskParameter="Value" PropertyName="ModuleVersion" />
</XmlRead>
<AssemblyInfo AssemblyVersion="$(ModuleVersion).00" CodeLanguage="CS"></AssemblyInfo>
<Message Text="MSBUILD: Assembly Version set to: $(ModuleVersion)" Importance="high"></Message>

<!-- Remove the temporary folders in case previous build failed in the middle of an operation-->
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DeleteTempFiles" Properties="step=start"></MSBuild>

<!-- Set the files to include in install package-->
<ItemGroup>
<InstallInclude Include="**\*.ascx" Exclude="packages\**" />
<InstallInclude Include="**\*.asmx" Exclude="packages\**" />
<InstallInclude Include="**\*.css" Exclude="packages\**" />
<InstallInclude Include="**\*.html" Exclude="packages\**;Tests\**" />
<InstallInclude Include="**\*.htm" Exclude="packages\**;package\**" />
<InstallInclude Include="**\*.resx" Exclude="packages\**" />
<InstallInclude Include="**\*.aspx" Exclude="packages\**" />
<InstallInclude Include="**\*.js" Exclude="packages\**" />
<InstallInclude Include="**\*.txt" Exclude="**\obj\**;**\_ReSharper*\**;packages\**;**\.git\**;" />
<InstallInclude Include="**\img\**" Exclude="packages\**" />
</ItemGroup>

<!-- Set the files to include in the source-->
<ItemGroup>
<SourceInclude Include="**\*.ascx" />
<SourceInclude Include="**\*.asmx" />
<SourceInclude Include="**\*.css" />
<SourceInclude Include="**\*.xsl" />
<SourceInclude Include="**\*.html" />
<SourceInclude Include="**\*.htm" />
<SourceInclude Include="**\*.resx" />
<SourceInclude Include="**\*.xml" Exclude="**\obj\**;**\_ReSharper*\**;**\.git\**;**\packages\**" />
<SourceInclude Include="**\*.aspx" />
<SourceInclude Include="**\*.js" />
<SourceInclude Include="**\*.txt" Exclude="**\obj\**;**\_ReSharper*\**;**\.git\**;" />
<SourceInclude Include="**\images\**" />
<SourceInclude Include="**\*.cs" Exclude="**\obj\**" />
<SourceInclude Include="**\*.cs.designer" />
<SourceInclude Include="**\*.csproj" />
<SourceInclude Include="**\*.targets" Exclude="**\packages\**" />
<SourceInclude Include="**\*.sln" />
<SourceInclude Include="**\img\**" Exclude="packages\**" />
</ItemGroup>

<!-- Files for setup -->
<CreateItem Include="$(MSBuildProjectDirectory)\DNN_Links.dnn">
<Output TaskParameter="Include" ItemName="PackageManifestFiles" />
</CreateItem>
<CreateItem Include="**\License.htm">
<Output TaskParameter="Include" ItemName="PackageTxtFiles" />
</CreateItem>
<CreateItem Include="**\ReleaseNotes.htm">
<Output TaskParameter="Include" ItemName="PackageTxtFiles" />
</CreateItem>
<CreateItem Include="**\*.SqlDataProvider">
<Output TaskParameter="Include" ItemName="SqlDataProviderFiles" />
</CreateItem>
<CreateItem Include="**\Cleanup.*.*.*.txt">
<Output TaskParameter="Include" ItemName="CleanupFiles" />
</CreateItem>

<!-- Grab files for install setup -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\bin\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
<Copy SourceFiles="@(SqlDataProviderFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package\%(RecursiveDir)" />
<Copy SourceFiles="@(PackageManifestFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />
<Copy SourceFiles="@(PackageTxtFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />
<Copy SourceFiles="@(CleanupFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />

<!-- Create the install resources.zip file -->
<Copy SourceFiles="@(InstallInclude)" DestinationFolder="$(MSBuildProjectDirectory)\ResourcesZip\%(RecursiveDir)" />
<CreateItem Include="$(MSBuildProjectDirectory)\ResourcesZip\**\*.*">
<Output TaskParameter="Include" ItemName="ResourcesContent" />
</CreateItem>
<Zip Files="@(ResourcesContent)" WorkingDirectory="$(MSBuildProjectDirectory)\ResourcesZip" ZipFileName="Resources.zip"/>
<Copy SourceFiles="$(MSBuildProjectDirectory)\Resources.zip" DestinationFolder="package/" />
<CreateItem Include="$(MSBuildProjectDirectory)\package\**\*.*">
<Output TaskParameter="Include" ItemName="OutputContent" />
</CreateItem>

<!-- Create the install package -->
<Zip Files="@(OutputContent)" WorkingDirectory="$(MSBuildProjectDirectory)\Package" ZipFileName="DNN_Links_$(ModuleVersion)_Install.zip" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\DNN_Links_$(ModuleVersion)_Install.zip" DestinationFolder="install/" />

<!-- Remove the temporary folders-->
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DeleteTempFiles" Properties="step=install"></MSBuild>

<!-- Grab files for source setup -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\bin\$(AssemblyName).dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
<Copy SourceFiles="$(MSBuildProjectDirectory)\bin\$(AssemblyName).pdb" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>
<Copy SourceFiles="@(SqlDataProviderFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package\%(RecursiveDir)" />
<Copy SourceFiles="@(PackageManifestFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />
<Copy SourceFiles="@(PackageTxtFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />
<Copy SourceFiles="@(CleanupFiles)" DestinationFolder="$(MSBuildProjectDirectory)\Package" />

<!-- Create the sources resources.zip file -->
<Copy SourceFiles="@(SourceInclude)" DestinationFolder="$(MSBuildProjectDirectory)\ResourcesZip\%(RecursiveDir)" />
<CreateItem Include="$(MSBuildProjectDirectory)\ResourcesZip\**\*.*">
<Output TaskParameter="Include" ItemName="SourceResourcesContent" />
</CreateItem>
<Zip Files="@(SourceResourcesContent)" WorkingDirectory="$(MSBuildProjectDirectory)\ResourcesZip" ZipFileName="Resources.zip"/>
<Copy SourceFiles="$(MSBuildProjectDirectory)\Resources.zip" DestinationFolder="package/" />
<CreateItem Include="$(MSBuildProjectDirectory)\package\**\*.*">
<Output TaskParameter="Include" ItemName="SourceOutputContent" />
</CreateItem>

<!-- Create the install package -->
<Zip Files="@(SourceOutputContent)" WorkingDirectory="$(MSBuildProjectDirectory)\Package" ZipFileName="DNN_Links_$(ModuleVersion)_Source.zip" />
<Copy SourceFiles="$(MSBuildProjectDirectory)\DNN_Links_$(ModuleVersion)_Source.zip" DestinationFolder="install/" />

<!-- Remove the temporary folders-->
<MSBuild Projects="$(MSBuildProjectFile)" Targets="DeleteTempFiles" Properties="step=source"></MSBuild>
<CallTarget Targets="DeleteTempFiles" UseResultsCache="false" />
</Target>
</Project>
16 changes: 16 additions & 0 deletions Cleanup.07.00.00.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bin\DotNetNuke.Modules.Links.pdb
App_Code\Links\Providers\DataProviders\SqlDataProvider\SqlDataProvider.vb
App_Code\Links\Providers\DataProviders\SqlDataProvider
App_Code\Links\Providers\DataProviders
App_Code\Links\Providers
App_Code\Links\Consts.vb
App_Code\Links\DataProvider.vb
App_Code\Links\Enums.vb
App_Code\Links\LinksController.vb
App_Code\Links\LinksFriend.vb
App_Code\Links\LinksInfo.vb
App_Code\Links\Utils.vb
App_Code\Links
DesktopModules\Links\EditLinks.ascx.vb
DesktopModules\Links\Links.ascx.vb
DesktopModules\Links\Settings.ascx.vb
126 changes: 126 additions & 0 deletions Components/FeatureController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Search.Entities;

namespace DotNetNuke.Modules.Links.Components
{
/// <summary>
/// Modules interface implementations
/// </summary>
public class FeatureController : ModuleSearchBase, IPortable
{
/// <summary>
/// Exports the module (Implements the IPortable interface)
/// </summary>
/// <param name="moduleID">The module ID</param>
/// <returns>XML String of the module data</returns>
public string ExportModule(int moduleID)
{
StringBuilder xml = new StringBuilder();
var links = LinkController.GetLinks(moduleID);
if (links.Count() != 0)
{
var module = ModuleController.Instance.GetModule(moduleID, DotNetNuke.Common.Utilities.Null.NullInteger, false);
xml.Append("<links>");
foreach (var link in links)
{
xml.Append("<link>");
xml.AppendFormat("<title>{0}</title>", XmlUtils.XMLEncode(link.Title));
xml.AppendFormat("<url>{0}</url>", XmlUtils.XMLEncode(link.Url));
xml.AppendFormat("<vieworder>{0}</vieworder>", XmlUtils.XMLEncode(link.ViewOrder.ToString()));
xml.AppendFormat("<description>{0}</description>", XmlUtils.XMLEncode(link.Description));
xml.AppendFormat("<newwindow>{0}</newwindow>", XmlUtils.XMLEncode(link.NewWindow.ToString()));
xml.AppendFormat("<trackclicks>{0}</trackclicks>", XmlUtils.XMLEncode(link.TrackClicks.ToString()));
xml.Append("</link>");
}

xml.Append("</links>");
}

return xml.ToString();
}

/// <summary>
/// Imports xml to fill the module data
/// </summary>
/// <param name="moduleID">The module ID importing</param>
/// <param name="content">The data representation to import in an XML string</param>
/// <param name="version">The version of the export</param>
/// <param name="userId">The user ID of the user importing the data</param>
public void ImportModule(int moduleID, string content, string version, int userId)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(content);
var xmlLinks = xmlDoc.SelectNodes("links");
foreach (XmlNode xmlLink in xmlLinks)
{
int viewOrder = int.TryParse(xmlLink.SelectSingleNode("vieworder").Value, out viewOrder) ? viewOrder : 0;
bool newWindow = bool.TryParse(xmlLink.SelectSingleNode("newwindow").Value, out newWindow) ? newWindow : false;
Link link = new Link
{
ModuleId = moduleID,
Title = xmlLink.SelectSingleNode("title").Value,
Url = DotNetNuke.Common.Globals.ImportUrl(moduleID, xmlLink.SelectSingleNode("url").Value),
ViewOrder = viewOrder,
Description = xmlLink.SelectSingleNode("description").Value
};

link.NewWindow = newWindow;

try
{
link.TrackClicks = bool.Parse(xmlLink.SelectSingleNode("trackclicks").Value);
}
catch
{
link.TrackClicks = false;
}

link.CreatedDate = DateTime.Now;
link.CreatedByUser = userId;
LinkController.DeleteLinkIfItExistsForModule(moduleID, link);
LinkController.AddLink(link);

// url tracking
UrlController objUrls = new UrlController();
var moduleInfo = ModuleController.Instance.GetModule(moduleID, Null.NullInteger, false);
objUrls.UpdateUrl(
moduleInfo.PortalID,
link.Url,
LinkController.ConvertUrlType(DotNetNuke.Common.Globals.GetURLType(link.Url)),
false,
link.TrackClicks,
moduleID,
link.NewWindow);
}
}

public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
{
// TODO: Would be better performing if we had a last modified date and soft deletes
DotNetNuke.Services.Search.Internals.InternalSearchController.Instance.DeleteSearchDocumentsByModule(moduleInfo.PortalID, moduleInfo.ModuleID, moduleInfo.ModuleDefID);
List<SearchDocument> searchDocuments = new List<SearchDocument>();
var links = LinkController.GetLinks(moduleInfo.ModuleID);
foreach (var link in links)
{
var searchDoc = new SearchDocument
{
UniqueKey = moduleInfo.ModuleID.ToString(),
PortalId = moduleInfo.PortalID,
Title = link.Title,
Description = link.Description,
Body = link.Description,
ModifiedTimeUtc = link.CreatedDate
};
searchDocuments.Add(searchDoc);
}

return searchDocuments;
}
}
}
Loading

0 comments on commit 86d96c8

Please sign in to comment.