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

Add new identical layouts module #153

Merged
merged 1 commit into from
Jul 19, 2017
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
4 changes: 4 additions & 0 deletions KInspector.Modules/Kentico.KInspector.Modules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<Compile Include="Modules\Content\RobotsTxtModule.cs" />
<Compile Include="Modules\Content\PageTypeAssignedToSiteModule.cs" />
<Compile Include="Modules\Content\UnusedPageTypesModule.cs" />
<Compile Include="Modules\Content\IdenticalTemplateLayoutsModule.cs" />
<Compile Include="Modules\Content\UnusedTemplatesModule.cs" />
<Compile Include="Modules\Content\WebPartsInTransformationsModule.cs" />
<Compile Include="Modules\Content\WorkflowConsistencyModule.cs" />
Expand Down Expand Up @@ -251,6 +252,9 @@
<Content Include="Scripts\UnusedPageTypesModule.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Scripts\IdenticalTemplateLayoutsModule.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Scripts\UnusedTemplatesModule.sql">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Xml.Serialization;
using Kentico.KInspector.Core;

namespace Kentico.KInspector.Modules
{
public class IdenticalTemplateLayoutsModule : IModule
{
public ModuleMetadata GetModuleMetadata()
{
return new ModuleMetadata
{
Name = "Templates with identical layouts",
SupportedVersions = new[] {
new Version("10.0")
},
Comment = @"Returns the list of templates with identical custom layouts (whitespace sensitive).",
};
}


public ModuleResults GetResults(IInstanceInfo instanceInfo)
{
var dbService = instanceInfo.DBService;
var identicalTemplateLayouts = dbService.ExecuteAndGetTableFromFile("IdenticalTemplateLayoutsModule.sql");

return new ModuleResults
{
Result = identicalTemplateLayouts
};
}
}
}
11 changes: 11 additions & 0 deletions KInspector.Modules/Scripts/IdenticalTemplateLayoutsModule.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SELECT
CodeNames = STUFF(
(SELECT ', ' + PageTemplateCodeName
FROM CMS_PageTemplate b
WHERE b.PageTemplateLayout = a.PageTemplateLayout
FOR XML PATH('')), 1, 2, ''),
a.PageTemplateLayout
FROM CMS_PageTemplate a
WHERE a.PageTemplateLayout is not NULL AND a.PageTemplateLayoutID is NULL
GROUP BY a.PageTemplateLayout
HAVING COUNT(*) > 1