Skip to content

Static Tags List #60

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

Merged
merged 11 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 6 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,9 @@
<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>
Comment on lines +1140 to +1142

This comment was marked as resolved.

<data name="AllGroups.Text" xml:space="preserve">
<value>-- All Groups -- </value>
</data>
Expand Down
10 changes: 10 additions & 0 deletions 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 UseStaticTagsListSubmit() As Boolean
Get
If (Settings.Contains(ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING)) Then
Return Convert.ToBoolean(Settings(ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING).ToString())
Else
Return ArticleConstants.USE_STATIC_TAGS_LIST_SUBMIT_SETTING_DEFAULT

This comment was marked as resolved.

End If
End Get
End Property

Public ReadOnly Property IncludeInPageName() As Boolean
Get
If (Settings.Contains(ArticleConstants.CATEGORY_NAME_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_SUBMIT_SETTING As String = "UseStaticTagsList"
Public Const USE_STATIC_TAGS_LIST_SUBMIT_SETTING_DEFAULT As Boolean = False

This comment was marked as duplicate.



' Category Security Settings
Public Const PERMISSION_CATEGORY_VIEW_SETTING As String = "PermissionCategoryView"
Expand Down
5 changes: 4 additions & 1 deletion ucEditTags.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ Namespace Ventrian.NewsArticles

Localization.LocalizeDataGrid(grdTags, Me.LocalResourceFile)

grdTags.DataSource = objTagController.List(Me.ModuleId, Null.NullInteger)
Dim objTags As ArrayList = objTagController.List(Me.ModuleId, Null.NullInteger)

objTags.Sort()
grdTags.DataSource = objTags
grdTags.DataBind()

If (grdTags.Items.Count > 0) Then
Expand Down
5 changes: 3 additions & 2 deletions ucSubmitNews.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@
</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>
<asp:textbox id="txtTags" cssclass="NormalTextBox" width="300" maxlength="255" runat="server" /><br />
<td>
<asp:textbox id="txtTags" cssclass="NormalTextBox" width="300" maxlength="255" runat="server" /><br />
<asp:Label ID="lblTags" ResourceKey="TagsHelp" runat="server" CssClass="Normal" />
<asp:ListBox ID="lstTags" runat="server" CssClass="Normal" DataTextField="Name" DataValueField="Name" Width="300px" Height="150px" SelectionMode="Multiple" />
</td>
</tr>
</table>
Expand Down
9 changes: 9 additions & 0 deletions ucSubmitNews.ascx.designer.vb

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

87 changes: 71 additions & 16 deletions ucSubmitNews.ascx.vb
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ Namespace Ventrian.NewsArticles
li.Selected = True
End If
Next
txtTags.Text = objArticle.Tags

If (ArticleSettings.UseStaticTagsListSubmit) Then
SelectTags(objArticle.Tags)
Else
txtTags.Text = objArticle.Tags
End If


Dim objPageController As New PageController
Dim pages As ArrayList = objPageController.GetPageList(_articleID)
Expand Down Expand Up @@ -336,6 +342,38 @@ Namespace Ventrian.NewsArticles

End Sub

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

Dim objTagController As New TagController
Dim objTags As ArrayList = objTagController.List(ModuleId, Null.NullInteger)

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

Private Sub SelectTags(ByVal tagList As String)
Dim objTagController As New TagController
For Each tag As String In tagList.Split(","c)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check for the case when tagList is Nothing, or does it always come across as an empty string if it's not set?

Also, consider using the Split overload that takes a StringSplitOptions to avoid having to handle empty tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, ArticleInfo.Tags is sourced from dbo.Ventrian_NewsArticles_SplitTags(@ArticleID int) which will always default to an empty string.

And good call 👍

If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, tag)

If Not (objTag Is Nothing) Then

This comment was marked as resolved.

Dim li As ListItem = lstTags.Items.FindByValue(objTag.Name)
If Not (li Is Nothing) Then

This comment was marked as resolved.

li.Selected = True
End If
End If
End If
Next
End Sub

Private Sub BindCustomFields()

Dim objCustomFieldController As New CustomFieldController()
Expand Down Expand Up @@ -1145,30 +1183,46 @@ Namespace Ventrian.NewsArticles
Dim objLinkedArticle As ArticleInfo = objArticleController.GetArticle(Convert.ToInt32(drpMirrorArticle.SelectedValue))

If (objLinkedArticle IsNot Nothing) Then
txtTags.Text = objLinkedArticle.Tags
If (ArticleSettings.UseStaticTagsListSubmit) Then
SelectTags(objLinkedArticle.Tags)
Else
txtTags.Text = objLinkedArticle.Tags
End If
End If
End If

Dim objTagController As New TagController
objTagController.DeleteArticleTag(articleID)

If (txtTags.Text <> "") Then
Dim tags As String() = txtTags.Text.Split(","c)
For Each tag As String In tags
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, tag)

If (objTag Is Nothing) Then
objTag = New TagInfo
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.ModuleID = ModuleId
objTag.TagID = objTagController.Add(objTag)
End If
If (ArticleSettings.UseStaticTagsListSubmit) Then
For Each li As ListItem In lstTags.Items
If (li.Selected) Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, li.Value)

objTagController.Add(articleID, objTag.TagID)
If Not (objTag Is Nothing) Then

This comment was marked as resolved.

objTagController.Add(articleID, objTag.TagID)
End If
End If
Next
Else
If (txtTags.Text <> "") Then
Dim tags As String() = txtTags.Text.Split(","c)
For Each tag As String In tags
If (tag <> "") Then
Dim objTag As TagInfo = objTagController.Get(ModuleId, tag)

If (objTag Is Nothing) Then
objTag = New TagInfo
objTag.Name = tag
objTag.NameLowered = tag.ToLower()
objTag.ModuleID = ModuleId
objTag.TagID = objTagController.Add(objTag)
End If

objTagController.Add(articleID, objTag.TagID)
End If
Next
End If
End If

End Sub
Expand Down Expand Up @@ -1517,6 +1571,7 @@ Namespace Ventrian.NewsArticles

BindStatus()
BindCategories()
BindTags()
SetVisibility()
BindArticle()
SetValidationGroup()
Expand Down
10 changes: 10 additions & 0 deletions ucViewOptions.ascx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
</tr>
</table>
<br />
<dnn:sectionhead id="dshTags" cssclass="Head" runat="server" text="Tag Settings" resourcekey="TagSettings"
section="tblTags" isexpanded="False" />
<table id="tblTags" cellspacing="2" cellpadding="2" summary="Appearance Design Table"
border="0" runat="server">
<tr>
<td class="SubHead" width="200"><dnn:label id="Label12" runat="server" resourcekey="UseStaticTagsList" controlname="chkUseStaticTagsList"></dnn:label></td>

This comment was marked as resolved.

<td valign="top"><asp:checkbox id="chkUseStaticTagsList" Runat="server" CssClass="NormalTextBox"></asp:checkbox></td>
</tr>
</table>
<br />
<dnn:sectionhead id="dshComments" cssclass="Head" runat="server" text="Comment Settings" resourcekey="CommentSettings"
section="tblComments" isexpanded="False" />
<table id="tblComments" cellspacing="2" cellpadding="2" summary="Appearance Design Table"
Expand Down
Loading