Skip to content

Commit

Permalink
NEED TO VERSION - Add DisplayOrder column to DnnForge_NewsArticles_Ar…
Browse files Browse the repository at this point in the history
…ticleTag table and allow for explicitly defining display order via ucSubmitNews UI
  • Loading branch information
Eric Wagner committed Mar 8, 2021
1 parent 0f641a8 commit de8c205
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 30 deletions.
6 changes: 6 additions & 0 deletions App_LocalResources/ucSubmitNews.ascx.resx
Original file line number Diff line number Diff line change
Expand Up @@ -459,4 +459,10 @@
<data name="plFolder.Text" xml:space="preserve">
<value>Upload Folder:</value>
</data>
<data name="plAllTags.Help" xml:space="preserve">
<value>Select all desired tags and add to Article Tags list.</value>
</data>
<data name="plArticleTags.Help" xml:space="preserve">
<value>Re-order article tags for display, and remove existing article tags.</value>
</data>
</root>
4 changes: 2 additions & 2 deletions Components/TagController.vb
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ Namespace Ventrian.NewsArticles

End Sub

Public Sub Add(ByVal articleID As Integer, ByVal tagID As Integer)
Public Sub Add(ByVal articleID As Integer, ByVal tagID As Integer, Optional ByVal displayOrder As Integer = 0)

RemoveCache(tagID)
DataProvider.Instance().AddArticleTag(articleID, tagID)
DataProvider.Instance().AddArticleTag(articleID, tagID, displayOrder)

End Sub

Expand Down
2 changes: 1 addition & 1 deletion Providers/DataProvider/DataProvider.vb
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Namespace Ventrian.NewsArticles
Public MustOverride Sub UpdateTag(ByVal tagID As Integer, ByVal moduleID As Integer, ByVal name As String, ByVal nameLowered As String, ByVal usages As Integer)
Public MustOverride Sub DeleteTag(ByVal tagID As Integer)

Public MustOverride Sub AddArticleTag(ByVal articleID As Integer, ByVal tagID As Integer)
Public MustOverride Sub AddArticleTag(ByVal articleID As Integer, ByVal tagID As Integer, Optional ByVal displayOrder As Integer = 0)
Public MustOverride Sub DeleteArticleTag(ByVal articleID As Integer)
Public MustOverride Sub DeleteArticleTagByTag(ByVal tagID As Integer)

Expand Down
4 changes: 2 additions & 2 deletions Providers/DataProvider/SqlDataProvider/SqlDataProvider.vb
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ Namespace Ventrian.NewsArticles
SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "DnnForge_NewsArticles_TagDelete", tagID)
End Sub

Public Overrides Sub AddArticleTag(ByVal articleID As Integer, ByVal tagID As Integer)
SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "DnnForge_NewsArticles_ArticleTagAdd", articleID, tagID)
Public Overrides Sub AddArticleTag(ByVal articleID As Integer, ByVal tagID As Integer, Optional ByVal displayOrder As Integer = 0)
SqlHelper.ExecuteNonQuery(ConnectionString, DatabaseOwner & ObjectQualifier & "DnnForge_NewsArticles_ArticleTagAdd", articleID, tagID, displayOrder)
End Sub

Public Overrides Sub DeleteArticleTag(ByVal articleID As Integer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
<None Include="00.07.99.SqlDataProvider" />
<None Include="00.08.00.SqlDataProvider" />
<None Include="00.08.04.SqlDataProvider" />
<None Include="VersionMe.SqlDataProvider" />
<None Include="00.09.02.SqlDataProvider" />
<None Include="Uninstall.SqlDataProvider" />
<Content Include="00.00.06.SqlDataProvider" />
Expand Down
62 changes: 62 additions & 0 deletions Providers/DataProvider/SqlDataProvider/VersionMe.SqlDataProvider
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
-- Add SortOrder column to DnnForge_NewsArticles_ArticleTag
IF (SELECT TOP 1 c.column_id
FROM sys.tables t
JOIN sys.all_columns c ON t.object_id = c.object_id
WHERE t.name = 'DnnForge_NewsArticles_ArticleTag' AND c.name = 'DisplayOrder') IS NULL
BEGIN

ALTER TABLE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag
ADD DisplayOrder INT

-- Backfill existing article tags
UPDATE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag
SET DisplayOrder = 0

END
GO

-- Add DisplayOrder param to DnnForge_NewsArticles_ArticleTagAdd store procedure
ALTER PROCEDURE {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTagAdd
@ArticleID int,
@TagID int,
@DisplayOrder int
AS
IF( (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag WHERE ArticleID = @ArticleID and TagID = @TagID) = 0 )
BEGIN
INSERT INTO
{databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag(ArticleID, TagID, DisplayOrder)
VALUES(@ArticleID, @TagID, @DisplayOrder)

UPDATE
{databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag
SET
Usages = (select count(*) from {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag pt where pt.TagID = @TagID)
WHERE
TagID = @TagID
END
GO

-- Alter Ventrian_NewsArticles_SplitTags function to order article tags by DisplayOrder field
ALTER FUNCTION {databaseOwner}{objectQualifier}Ventrian_NewsArticles_SplitTags
(@ArticleID int)
RETURNS nvarchar(2000)
AS
BEGIN

DECLARE @p_str nvarchar(2000)
SET @p_str = ''

SELECT @p_str = @p_str + ',' + CAST(t.[Name] AS NVARCHAR(50))
FROM {databaseOwner}{objectQualifier}DnnForge_NewsArticles_Tag t, {databaseOwner}{objectQualifier}DnnForge_NewsArticles_ArticleTag at
WHERE t.TagID = at.TagID and at.ArticleID = @ArticleID
ORDER BY at.DisplayOrder

IF( LEN(@p_str) > 0 )
BEGIN
SELECT @p_str = SUBSTRING(@p_str, 2, (LEN(@p_str)-1))
END

RETURN LTRIM(@p_str)

END
GO
16 changes: 14 additions & 2 deletions ucSubmitNews.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,23 @@
</td>
</tr>
<tr runat="Server" id="trTags">
<td class="SubHead" width="150"><dnn:label id="plTags" text="Tags:" runat="server" controlname="txtTags"></dnn:label></td>
<td>
<td class="SubHead" id="tdTxtTagsTitle" width="150"><dnn:label id="plTags" text="Tags:" runat="server" controlname="txtTags"></dnn:label></td>
<td runat="server" id="tdTxtTags">
<asp:textbox id="txtTags" cssclass="NormalTextBox" width="300" maxlength="255" runat="server" /><br />
<asp:Label ID="lblTags" ResourceKey="TagsHelp" runat="server" CssClass="Normal" />
</td>
<td class="SubHead" id="tdAllTagsTitle" width="150"><dnn:label id="plAllTags" text="All Tags:" runat="server"></dnn:label></td>
<td runat="server" id="tdAllTagsList">
<asp:ListBox ID="lstTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" Height="150px" SelectionMode="Multiple" />
<asp:imagebutton id="addTags" resourcekey="btnAddTags.Help" runat="server" alternatetext="Add Tags To Article" commandname="add" imageurl="~/images/action_import.gif"></asp:imagebutton>
</td>
<td runat="server" id="tdStaticTagsList">
<dnn:label id="plArticleTags" text="Article Tags:" runat="server" controlname="txtArticleTags"></dnn:label>
<asp:ListBox ID="lstFinalTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" Height="150px" SelectionMode="Single" />

<asp:imagebutton id="cmdUp" resourcekey="cmdUp.Help" runat="server" alternatetext="Move Tag Up In Tags List" commandname="up" imageurl="~/images/up.gif"></asp:imagebutton>
<asp:imagebutton id="cmdDown" resourcekey="cmdDown.Help" runat="server" alternatetext="Move Tag Down In Tags List" commandname="down" imageurl="~/images/dn.gif"></asp:imagebutton>
<asp:imagebutton id="cmdDeleteTag" resourcekey="cmdDeleteTag.Help" runat="server" alternatetext="Delete Tag From Tags List" commandname="cmdDeleteTag" imageurl="~/images/action_delete.gif"></asp:imagebutton>
</td>
</tr>
</table>
Expand Down
108 changes: 108 additions & 0 deletions ucSubmitNews.ascx.designer.vb

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

Loading

0 comments on commit de8c205

Please sign in to comment.