Skip to content

Commit

Permalink
Merge pull request #60 from epdubi/static-tags-list
Browse files Browse the repository at this point in the history
Static Tags List
  • Loading branch information
skamphuis authored Feb 2, 2022
2 parents 06a155f + fc8772b commit 2cf6c8d
Show file tree
Hide file tree
Showing 19 changed files with 931 additions and 380 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>
9 changes: 9 additions & 0 deletions App_LocalResources/ucViewOptions.ascx.resx
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,9 @@
<data name="CategorySettings.Text" xml:space="preserve">
<value>Category Settings</value>
</data>
<data name="TagSettings.Text" xml:space="preserve">
<value>Tag Settings</value>
</data>
<data name="DefaultCategories.Help" xml:space="preserve">
<value>Check categories to auto-select them on the create article screen.</value>
</data>
Expand Down Expand Up @@ -1134,6 +1137,12 @@
<data name="CategoryFilterSubmit.Text" xml:space="preserve">
<value>Filter Category Submit</value>
</data>
<data name="UseStaticTagsList.Text" xml:space="preserve">
<value>Use Static Tags List</value>
</data>
<data name="UseStaticTagsList.Help" xml:space="preserve">
<value>Check to only allow existing tags to be used on submit article screen, otherwise allow article authors to create new tags while authoring an article. When checked, a list box will be used to select existing tags (similar to categories), rather then the text box used when unchecked.</value>
</data>
<data name="AllGroups.Text" xml:space="preserve">
<value>-- All Groups -- </value>
</data>
Expand Down
12 changes: 11 additions & 1 deletion Components/ArticleSettings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,16 @@ Namespace Ventrian.NewsArticles
End Get
End Property

Public ReadOnly Property UseStaticTagsList() As Boolean
Get
If (Settings.Contains(ArticleConstants.USE_STATIC_TAGS_LIST_SETTING)) Then
Return Convert.ToBoolean(Settings(ArticleConstants.USE_STATIC_TAGS_LIST_SETTING).ToString())
Else
Return ArticleConstants.USE_STATIC_TAGS_LIST_SETTING_DEFAULT
End If
End Get
End Property

Public ReadOnly Property IncludeInPageName() As Boolean
Get
If (Settings.Contains(ArticleConstants.CATEGORY_NAME_SETTING)) Then
Expand Down Expand Up @@ -355,7 +365,7 @@ Namespace Ventrian.NewsArticles
End If
End Get
End Property

Public ReadOnly Property EnablePortalFiles() As Boolean
Get
If (Settings.Contains(ArticleConstants.ENABLE_PORTAL_FILES_SETTING)) Then
Expand Down
3 changes: 3 additions & 0 deletions Components/Common/ArticleConstants.vb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ Namespace Ventrian.NewsArticles
Public Const CATEGORY_FILTER_SUBMIT_SETTING_DEFAULT As Boolean = False
Public Const CATEGORY_SORT_SETTING As String = "CategorySortType"
Public Const CATEGORY_SORT_SETTING_DEFAULT As CategorySortType = CategorySortType.SortOrder
Public Const USE_STATIC_TAGS_LIST_SETTING As String = "UseStaticTagsList"
Public Const USE_STATIC_TAGS_LIST_SETTING_DEFAULT As Boolean = False


' Category Security Settings
Public Const PERMISSION_CATEGORY_VIEW_SETTING As String = "PermissionCategoryView"
Expand Down
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
1 change: 1 addition & 0 deletions LatestArticlesOptions.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<td>
<asp:RadioButtonList ID="rdoTagsMatchOperator" Runat="server" CssClass="Normal" RepeatDirection="Horizontal" />
<asp:textbox id="txtTags" cssclass="NormalTextBox" width="300" maxlength="255" runat="server" /><br />
<asp:ListBox ID="lstTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" Height="150px" SelectionMode="Multiple" />
<asp:Label ID="lblTags" ResourceKey="TagsHelp" runat="server" CssClass="Normal" />
</td>
</tr>
Expand Down
9 changes: 9 additions & 0 deletions LatestArticlesOptions.ascx.designer.vb

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

160 changes: 122 additions & 38 deletions LatestArticlesOptions.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Namespace Ventrian.NewsArticles
End If

If (drpModuleID.Items.Count > 0) Then
BindTags()
BindCategories()
BindCustomFields()
End If
Expand All @@ -174,12 +175,95 @@ Namespace Ventrian.NewsArticles

End Sub

Private Function UseStaticTagsList() As Boolean

If Not (drpModuleID.Items.Count > 0) Then
Return ArticleConstants.USE_STATIC_TAGS_LIST_SETTING_DEFAULT
End If

Dim selectedModuleValues As String() = drpModuleID.SelectedValue.Split(Convert.ToChar("-"))
Dim objModuleController As New ModuleController
Dim selectedArticlesModule As ModuleInfo = objModuleController.GetModule(Convert.ToInt32(selectedModuleValues(1)), Convert.ToInt32(selectedModuleValues(0)), False)

If Not selectedArticlesModule.ModuleSettings.Contains(ArticleConstants.USE_STATIC_TAGS_LIST_SETTING) Then
Return ArticleConstants.USE_STATIC_TAGS_LIST_SETTING_DEFAULT
End If

Return Convert.ToBoolean(selectedArticlesModule.ModuleSettings(ArticleConstants.USE_STATIC_TAGS_LIST_SETTING).ToString())

End Function

Private Sub SelectAllTags(ByVal tagIdList As String)

Dim objTagController As New TagController
For Each tagId As String In tagIdList.Split(New Char() {","c}, StringSplitOptions.RemoveEmptyEntries)
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(tagId))

If objTag IsNot Nothing Then
Dim li As ListItem = lstTags.Items.FindByValue(objTag.Name)
If li IsNot Nothing Then
li.Selected = True
End If
End If
Next

End Sub

Private Sub BindTags()
If UseStaticTagsList() Then
lblTags.Visible = False
txtTags.Visible = False

lstTags.Visible = True
FillTagsList()
Else
lstTags.Visible = False

lblTags.Visible = True
txtTags.Visible = True
End If

If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAGS)) Then
Dim tags As String = Settings(ArticleConstants.LATEST_ARTICLES_TAGS).ToString()
If (tags <> "" And drpModuleID.Items.Count > 0) Then
If UseStaticTagsList() Then
SelectAllTags(tags)
Else
Dim objTagController As New TagController()
For Each tag As String In tags.Split(","c)
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(tag))
If (objTag IsNot Nothing) Then
If (txtTags.Text <> "") Then
txtTags.Text = txtTags.Text + "," + objTag.Name
Else
txtTags.Text = objTag.Name
End If
End If
Next
End If
End If
End If
End Sub

Private Sub FillTagsList()
If (drpModuleID.Items.Count > 0) Then
Dim objTagController As New TagController
Dim objTags As ArrayList = objTagController.List(Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1)), Null.NullInteger)

objTags.Sort()
lstTags.DataSource = objTags
lstTags.DataBind()
End If
End Sub

Private Sub BindSettings()

If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_MODULE_ID) And Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAB_ID)) Then
If Not (drpModuleID.Items.FindByValue(Settings(ArticleConstants.LATEST_ARTICLES_TAB_ID).ToString() & "-" & Settings(ArticleConstants.LATEST_ARTICLES_MODULE_ID).ToString()) Is Nothing) Then
drpModuleID.SelectedValue = Settings(ArticleConstants.LATEST_ARTICLES_TAB_ID).ToString() & "-" & Settings(ArticleConstants.LATEST_ARTICLES_MODULE_ID).ToString()
End If

BindTags()
BindCategories()
BindCustomFields()
End If
Expand Down Expand Up @@ -241,23 +325,6 @@ Namespace Ventrian.NewsArticles
End If
End If

If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAGS)) Then
Dim objTagController As New TagController()
Dim tags As String = Settings(ArticleConstants.LATEST_ARTICLES_TAGS).ToString()
If (tags <> "" And drpModuleID.Items.Count > 0) Then
For Each tag As String In tags.Split(","c)
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(tag))
If (objTag IsNot Nothing) Then
If (txtTags.Text <> "") Then
txtTags.Text = txtTags.Text + "," + objTag.Name
Else
txtTags.Text = objTag.Name
End If
End If
Next
End If
End If

If (rdoTagsMatchOperator.Items.Count > 0) Then
rdoTagsMatchOperator.Items(0).Selected = True
End If
Expand Down Expand Up @@ -599,31 +666,47 @@ Namespace Ventrian.NewsArticles

Dim tags As String = ""
If (drpModuleID.Items.Count > 0) Then
For Each tag As String In txtTags.Text.Split(","c)
If (tag <> "") Then
Dim objTagController As New TagController()
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1)), tag.ToLower())
If (objTag IsNot Nothing) Then
If (tags = "") Then
tags = objTag.TagID.ToString()
Else
tags = tags & "," & objTag.TagID.ToString()
Dim objTagController As New TagController()

If UseStaticTagsList() Then
For Each li As ListItem In lstTags.Items
If li.Selected Then
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1)), li.Value.ToLower())
If (objTag IsNot Nothing) Then
If (tags = "") Then
tags = objTag.TagID.ToString()
Else
tags = tags & "," & objTag.TagID.ToString()
End If
End If
Else
objTag = New TagInfo()
objTag.ModuleID = Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1))
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.Usages = 0
objTag.TagID = objTagController.Add(objTag)
If (tags = "") Then
tags = objTag.TagID.ToString()
End If
Next
Else
For Each tag As String In txtTags.Text.Split(","c)
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1)), tag.ToLower())
If (objTag IsNot Nothing) Then
If (tags = "") Then
tags = objTag.TagID.ToString()
Else
tags = tags & "," & objTag.TagID.ToString()
End If
Else
tags = tags & "," & objTag.TagID.ToString()
objTag = New TagInfo()
objTag.ModuleID = Convert.ToInt32(drpModuleID.SelectedValue.Split("-"c)(1))
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.Usages = 0
objTag.TagID = objTagController.Add(objTag)
If (tags = "") Then
tags = objTag.TagID.ToString()
Else
tags = tags & "," & objTag.TagID.ToString()
End If
End If
End If
End If
Next
Next
End If
End If
objModuleController.UpdateModuleSetting(ModuleId, ArticleConstants.LATEST_ARTICLES_TAGS, tags)
objModuleController.UpdateModuleSetting(Me.ModuleId, ArticleConstants.LATEST_ARTICLES_TAGS_MATCH_OPERATOR, rdoTagsMatchOperator.SelectedValue)
Expand Down Expand Up @@ -714,6 +797,7 @@ Namespace Ventrian.NewsArticles
Private Sub drpModuleID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpModuleID.SelectedIndexChanged

Try
BindTags()
BindCategories()
BindCustomFields()
Catch exc As Exception 'Module failed to load
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
Loading

0 comments on commit 2cf6c8d

Please sign in to comment.