diff --git a/App_LocalResources/Settings.ascx.resx b/App_LocalResources/Settings.ascx.resx new file mode 100644 index 0000000..eabed37 --- /dev/null +++ b/App_LocalResources/Settings.ascx.resx @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + SiteNews Settings + + + Check to include the name of the author, if availble. + + + Include Author + + + Check to display the body of found items, if available. + + + Include Body + + + Check to display the description of found items, if avilable. + + + Include Description + + + Check to display an information about how many resutls were found in the selected time span. + + + Include Info panel + + + Check to include the search type in the search result. This setting is meant for admins and developers to find possible errors. + + + Include search type + + + Check to include the search result's snippet, if available + + + Include Snippet + + + Enter the number of days to display the last modifications. + + + Number of days + + + Enter the number of results to display + + + Number of results + + + Enter the number of results per page + + + Page size + + + Rendering + + + Select the search types to display in the result. + + + Search Types + + \ No newline at end of file diff --git a/App_LocalResources/View.ascx.resx b/App_LocalResources/View.ascx.resx new file mode 100644 index 0000000..0543c40 --- /dev/null +++ b/App_LocalResources/View.ascx.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + {0} new or changed content items found within the last {1} days. + + + No new or changed content items from the site could be found. + + + Type + + \ No newline at end of file diff --git a/Components/BusinessController.cs b/Components/BusinessController.cs new file mode 100644 index 0000000..ee469df --- /dev/null +++ b/Components/BusinessController.cs @@ -0,0 +1,33 @@ +/* +DNN-Connect - http://dnn-connect.org +Copyright (c) 2017 +by DNN-Connect +Written by Michael Tobisch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +using DotNetNuke.Entities.Modules; + +namespace Connect.Modules.SiteNews +{ + public class BusinessController : IUpgradeable + { + public string UpgradeModule(string version) + { + return string.Format("Upgrading to version {0}", version); + } + } +} \ No newline at end of file diff --git a/Components/SearchDataProvider.cs b/Components/SearchDataProvider.cs new file mode 100644 index 0000000..45410b7 --- /dev/null +++ b/Components/SearchDataProvider.cs @@ -0,0 +1,158 @@ +/* +DNN-Connect - http://dnn-connect.org +Copyright (c) 2017 +by DNN-Connect +Written by Michael Tobisch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Portals; +using DotNetNuke.Entities.Tabs; +using DotNetNuke.Entities.Users; +using DotNetNuke.Services.Search.Controllers; +using DotNetNuke.Services.Search.Entities; +using DotNetNuke.Services.Search.Internals; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; + +namespace Connect.Modules.SiteNews +{ + public class SearchDataProvider + { + private ModuleInfo _module; + private UserInfo _user; + private PortalSettings _portalSettings; + protected int NumberOfDays + { + get + { + object o = _module.ModuleSettings["NumberOfDays"]; + int numberOfDays; + try + { + if (!(Int32.TryParse(o.ToString(), out numberOfDays))) + numberOfDays = 5; + } + catch (Exception) + { + numberOfDays = 5; + } + return numberOfDays; + } + } + + protected List SearchTypes + { + get + { + object o = _module.ModuleSettings["SearchTypes"]; + List searchTypes = new List(); + if (o == null) + { + searchTypes = SiteNewsHelpers.AllSearchTypes.Select(x => x.SearchTypeId).ToList(); + } + else + { + searchTypes = o.ToString().Split(new char[] { ',' }).Select(int.Parse).ToList(); + } + return searchTypes; + } + } + + protected int NumberOfResults + { + get + { + object o = _module.ModuleSettings["NumberOfResults"]; + int numberOfResults; + try + { + if (!(Int32.TryParse(o.ToString(), out numberOfResults))) + numberOfResults = 25; + } + catch (Exception) + { + numberOfResults = 25; + } + return numberOfResults; + } + } + + protected bool IncludeDescription + { + get { return Convert.ToBoolean(_module.ModuleSettings["IncludeDescription"]); } + } + + protected bool IncludeBody + { + get { return Convert.ToBoolean(_module.ModuleSettings["IncludeBody"]); } + } + + protected bool IncludeAuthor + { + get { return Convert.ToBoolean(_module.ModuleSettings["IncludeAuthor"]); } + } + + protected bool IncludeSnippet + { + get { return Convert.ToBoolean(_module.ModuleSettings["IncludeSnippet"]); } + } + + public SearchDataProvider(ModuleInfo Module, UserInfo User, PortalSettings PortalSettings) + { + _module = Module; + _user = User; + _portalSettings = PortalSettings; + } + + public IList GetNewItems() + { + IList searchResults = null; + + SearchQuery query = new SearchQuery(); + query.AllowLeadingWildcard = true; + query.KeyWords = "*"; + query.PortalIds = new List() { _module.PortalID }; + query.Locale = CultureInfo.CurrentCulture.Name; + query.BeginModifiedTimeUtc = DateTime.UtcNow.AddDays(NumberOfDays * -1); + query.EndModifiedTimeUtc = DateTime.UtcNow; + query.SearchTypeIds = SearchTypes; + query.SortField = SortFields.LastModified; + query.SortDirection = SortDirections.Descending; + query.WildCardSearch = true; + + int numberOfResults = NumberOfResults; + + query.PageSize = numberOfResults; + + searchResults = SearchController.Instance.SiteSearch(query).Results + .Where( + r => ( + ((r.SearchTypeId == SearchHelper.Instance.GetSearchTypeByName("module").SearchTypeId) && (r.ModuleId != _module.ModuleID)) || + ((r.SearchTypeId == SearchHelper.Instance.GetSearchTypeByName("tab").SearchTypeId) && (r.TabId != _module.TabID)) + ) + ) + .GroupBy(r => new { r.SearchTypeId, r.ModuleId, r.TabId, r.Title, r.Description }) + .Select(g => g.LastOrDefault()) + .ToList(); + + return searchResults; + } + } +} \ No newline at end of file diff --git a/Components/SiteNewsHelpers.cs b/Components/SiteNewsHelpers.cs new file mode 100644 index 0000000..b92da59 --- /dev/null +++ b/Components/SiteNewsHelpers.cs @@ -0,0 +1,100 @@ +/* +DNN-Connect - http://dnn-connect.org +Copyright (c) 2017 +by DNN-Connect +Written by Michael Tobisch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +using DotNetNuke.Entities.Modules; +using DotNetNuke.Entities.Tabs; +using DotNetNuke.Services.Search.Entities; +using DotNetNuke.Services.Search.Internals; +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Connect.Modules.SiteNews +{ + public static class SiteNewsHelpers + { + public const string SearchableModulesResourceFile = "/DesktopModules/Admin/SearchResults/App_LocalResources/SearchableModules.resx"; + public static List AllSearchTypes + { + get + { + return (List)SearchHelper.Instance.GetSearchTypes(); + } + } + + public static int GetTabIDFromUrl(string url, int moduleID, int portalID) + { + int getTabIDFromUrl = 0; + + if (url.ToLower().IndexOf("tabid") > 0) + { + Int32.TryParse(Regex.Match(url, "tabid[=/](\\d+)", RegexOptions.IgnoreCase).Groups[1].Value, out getTabIDFromUrl); + } + + if (getTabIDFromUrl == 0) + { + IList modules = ModuleController.Instance.GetTabModulesByModule(moduleID); + + foreach (ModuleInfo module in modules) + { + TabInfo tab = TabController.Instance.GetTab(module.TabID, portalID); + if (url.StartsWith(tab.FullUrl)) + { + getTabIDFromUrl = tab.TabID; + break; + } + } + } + return getTabIDFromUrl; + } + + public static bool IsProfilePage(int tabID, int userTabID, int portalID) + { + TabInfo tab = TabController.Instance.GetTab(tabID, portalID); + bool isProfilePage = (tab.TabID == userTabID); + + while (!(isProfilePage)) + { + if (tab.ParentId <= 0) + break; + tab = TabController.Instance.GetTab(tab.ParentId, tab.PortalID); + isProfilePage = (tab.TabID == userTabID); + } + return isProfilePage; + } + + public static bool IsAdminPage(int tabID, int adminTabID, int portalID) + { + TabInfo tab = TabController.Instance.GetTab(tabID, portalID); + bool isAdminPage = (tab.TabID == adminTabID); + + while (!(isAdminPage)) + { + if (tab.ParentId <= 0) + break; + tab = TabController.Instance.GetTab(tab.ParentId, tab.PortalID); + isAdminPage = (tab.TabID == adminTabID); + } + return isAdminPage; + + } + } +} \ No newline at end of file diff --git a/Documentation/DNN-Connect-SiteNews.License.txt b/Documentation/DNN-Connect-SiteNews.License.txt new file mode 100644 index 0000000..6d3ca5a --- /dev/null +++ b/Documentation/DNN-Connect-SiteNews.License.txt @@ -0,0 +1,24 @@ +
+

License

+

+ © 2017 dnnWerk.at ( dnnwerk.at )
+ Written by Michael Tobisch +

+

+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + to permit persons to whom the Software is furnished to do so, subject to the following conditions: +

+

+ The above copyright notice and this permission notice shall be included in all copies or substantial portions + of the Software. +

+

+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED + TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +

+
diff --git a/Documentation/DNN-Connect-SiteNews.ReleaseNotes.txt b/Documentation/DNN-Connect-SiteNews.ReleaseNotes.txt new file mode 100644 index 0000000..fe28914 --- /dev/null +++ b/Documentation/DNN-Connect-SiteNews.ReleaseNotes.txt @@ -0,0 +1,25 @@ +

DNN-Connect SiteNews

+

+ dnnWerk.at for DNN-Connect
+ noreply@dnnwerk.at
+ dnnwerk.at
+ dnn-connect.org +

+
+
+

About DNN-Connect SiteNews

+

+ Module to display new or changed content from the site. +

+

Requirements:

+
    +
  • DNN Platform 07.04.02 or later
  • +
+

Version History:

+
    +
  • + Version 01.00.00
    + Initial Release +
  • +
+
diff --git a/Documentation/License.de-AT.txt b/Documentation/License.de-AT.txt new file mode 100644 index 0000000..e1ce53f --- /dev/null +++ b/Documentation/License.de-AT.txt @@ -0,0 +1,23 @@ +
+

License

+

+ © 2017 helferlein.com ( helferlein.com )
+ Autor: Michael Tobisch +

+

+ Hiermit wird unentgeltlich jeder Person, die eine Kopie der Software und der zugehörigen Dokumentationen + (die "Software") erhält, die Erlaubnis erteilt, sie uneingeschränkt zu benutzen, inklusive und ohne Ausnahme + dem Recht, sie zu verwenden, kopieren, ändern, fusionieren, verlegen, verbreiten, unterlizenzieren und/oder + zu verkaufen, und Personen, die diese Software erhalten, diese Rechte zu geben, unter den folgenden Bedingungen: +

+

+ Der obige Urheberrechtsvermerk und dieser Erlaubnisvermerk sind in allen Kopien oder Teilkopien der Software beizulegen. +

+

+ DIE SOFTWARE WIRD OHNE JEDE AUSDRÜCKLICHE ODER IMPLIZIERTE GARANTIE BEREITGESTELLT, EINSCHLIESSLICH DER GARANTIE ZUR + BENUTZUNG FÜR DEN VORGESEHENEN ODER EINEM BESTIMMTEN ZWECK SOWIE JEGLICHER RECHTSVERLETZUNG, JEDOCH NICHT DARAUF + BESCHRÄNKT. IN KEINEM FALL SIND DIE AUTOREN ODER COPYRIGHTINHABER FÜR JEGLICHEN SCHADEN ODER SONSTIGE ANSPRÜCHE + HAFTBAR ZU MACHEN, OB INFOLGE DER ERFÜLLUNG EINES VERTRAGES, EINES DELIKTES ODER ANDERS IM ZUSAMMENHANG MIT DER + SOFTWARE ODER SONSTIGER VERWENDUNG DER SOFTWARE ENTSTANDEN. +

+
diff --git a/Documentation/ReleaseNotes.de-AT.txt b/Documentation/ReleaseNotes.de-AT.txt new file mode 100644 index 0000000..c27fda5 --- /dev/null +++ b/Documentation/ReleaseNotes.de-AT.txt @@ -0,0 +1,25 @@ +

DNN-Connect SiteNews Sprachpaket Deutsch (Österreich)

+

+ helferlein.com for DNN-Connect
+ mt@helferlein.com
+ helferlein.com
+ dnn-connect.org +

+
+
+

Über DNN-Connect SiteNews

+

+ Deutsch (Österreichisches) Sprachpaket für DNN-Connect SiteNews. +

+

Systemvoraussetzungen:

+
    +
  • DNN Platform 07.04.02 oder höher
  • +
+

Versionsgeschichte:

+
    +
  • + Version 01.00.00
    + Ursprüngliche Veröffentlichung +
  • +
+
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..3689bb1 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,34 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("DNN-Connect SiteNews")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Dnn-Connect")] +[assembly: AssemblyProduct("SiteNews")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5ef01dd5-84a1-49f3-9232-067440288455")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("01.00.00")] +[assembly: AssemblyFileVersion("01.00.00")] diff --git a/Settings.ascx b/Settings.ascx new file mode 100644 index 0000000..5ad9809 --- /dev/null +++ b/Settings.ascx @@ -0,0 +1,108 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Settings.ascx.cs" Inherits="Connect.Modules.SiteNews.Settings" %> +<%@ Register TagName="label" TagPrefix="dnn" Src="~/controls/labelcontrol.ascx" %> + +
+ + + + + + + + +
+ +
+ + +
+ +
+ + + + + + + +
+ +
+ + + + + + + + +
+ +

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
\ No newline at end of file diff --git a/Settings.ascx.cs b/Settings.ascx.cs new file mode 100644 index 0000000..bba355e --- /dev/null +++ b/Settings.ascx.cs @@ -0,0 +1,282 @@ +/* +DNN-Connect - http://dnn-connect.org +Copyright (c) 2017 +by DNN-Connect +Written by Michael Tobisch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +using DotNetNuke.Entities.Modules; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Services.Localization; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.UI.WebControls; + +namespace Connect.Modules.SiteNews +{ + public partial class Settings : ModuleSettingsBase + { + private ModuleController _controller = null; + + protected ModuleController Controller + { + get + { + if (_controller == null) + _controller = new ModuleController(); + return _controller; + } + } + + protected int NumberOfDays + { + get + { + object o = Settings["NumberOfDays"]; + int numberOfDays; + try + { + if (!(Int32.TryParse(o.ToString(), out numberOfDays))) + numberOfDays = 5; + } + catch (Exception) + { + numberOfDays = 5; + } + return numberOfDays; + } + set + { + UpdateIntegerSetting("NumberOfDays", (value == 5 ? (int?)null : value)); + } + } + + protected string SearchTypes + { + get + { + object o = Settings["SearchTypes"]; + if (o == null) + return SiteNewsHelpers.AllSearchTypes.Select(x => x.SearchTypeId.ToString()).Aggregate((current, next) => current + "," + next); + else + return o.ToString(); + } + set + { + UpdateTextSetting("SearchTypes", value); + } + } + + protected int NumberOfResults + { + get + { + object o = Settings["NumberOfResults"]; + int numberOfResults; + try + { + if (!(Int32.TryParse(o.ToString(), out numberOfResults))) + numberOfResults = 25; + } + catch (Exception) + { + numberOfResults = 25; + } + return numberOfResults; + } + set + { + UpdateIntegerSetting("NumberOfResults", (value == 25 ? (int?)null : value)); + } + } + + protected int PageSize + { + get + { + int pageSize = 5; + object o = Settings["PageSize"]; + if (o != null) + pageSize = Convert.ToInt32(o); + return pageSize; + } + set + { + UpdateIntegerSetting("PageSize", (value == 5 ? (int?)null : value)); + } + } + + protected bool IncludeSearchType + { + get { return Convert.ToBoolean(Settings["IncludeSearchType"]); } + set { UpdateBooleanSetting("IncludeSearchType", value); } + } + + protected bool IncludeInfo + { + get { return Convert.ToBoolean(Settings["IncludeInfo"]); } + set { UpdateBooleanSetting("IncludeInfo", value); } + } + + protected bool IncludeDescription + { + get { return Convert.ToBoolean(Settings["IncludeDescription"]); } + set { UpdateBooleanSetting("IncludeDescription", value); } + } + + protected bool IncludeBody + { + get { return Convert.ToBoolean(Settings["IncludeBody"]); } + set { UpdateBooleanSetting("IncludeBody", value); } + } + + protected bool IncludeAuthor + { + get { return Convert.ToBoolean(Settings["IncludeAuthor"]); } + set { UpdateBooleanSetting("IncludeAuthor", value); } + } + + protected bool IncludeSnippet + { + get { return Convert.ToBoolean(Settings["IncludeSnippet"]); } + set { UpdateBooleanSetting("IncludeSnippet", value); } + } + + public override void LoadSettings() + { + try + { + if (!(Page.IsPostBack)) + { + NumberOfDaysRadioButtons.SelectedValue = NumberOfDays.ToString(); + NumberOfResultsRadioButtons.SelectedValue = NumberOfResults.ToString(); + PageSizeRadioButtons.SelectedValue = PageSize.ToString(); + IncludeSearchTypeCheckBox.Checked = IncludeSearchType; + IncludeInfoCheckBox.Checked = IncludeInfo; + IncludeDescriptionCheckBox.Checked = IncludeDescription; + IncludeBodyCheckBox.Checked = IncludeBody; + IncludeAuthorCheckBox.Checked = IncludeAuthor; + IncludeSnippetCheckBox.Checked = IncludeSnippet; + } + } + catch (Exception exc) //Module failed to load + { + Exceptions.ProcessModuleLoadException(this, exc); + } + } + + public override void UpdateSettings() + { + try + { + NumberOfDays = Convert.ToInt32(NumberOfDaysRadioButtons.SelectedValue); + List selectedItems = new List(); + foreach (ListItem li in SearchTypeCheckBoxes.Items) + { + if (li.Selected) selectedItems.Add(li.Value); + } + SearchTypes = selectedItems.Aggregate((current, next) => current + "," + next); + NumberOfResults = Convert.ToInt32(NumberOfResultsRadioButtons.SelectedValue); + PageSize = Convert.ToInt32(PageSizeRadioButtons.SelectedValue); + IncludeSearchType = IncludeSearchTypeCheckBox.Checked; + IncludeInfo = IncludeInfoCheckBox.Checked; + IncludeDescription = IncludeDescriptionCheckBox.Checked; + IncludeBody = IncludeBodyCheckBox.Checked; + IncludeAuthor = IncludeAuthorCheckBox.Checked; + IncludeSnippet = IncludeSnippetCheckBox.Checked; + } + catch (Exception ex) //Module failed to load + { + Exceptions.ProcessModuleLoadException(this, ex); + } + } + + protected void SearchTypeCheckBoxes_Load(object sender, EventArgs e) + { + if (!(Page.IsPostBack)) + { + CheckBoxList searchTypeCheckBoxes = (CheckBoxList)sender; + searchTypeCheckBoxes.DataSource = SiteNewsHelpers.AllSearchTypes; + searchTypeCheckBoxes.DataTextField = "SearchTypeName"; + searchTypeCheckBoxes.DataValueField = "SearchTypeId"; + searchTypeCheckBoxes.DataBind(); + + foreach (ListItem li in searchTypeCheckBoxes.Items) + { + string caption = Localization.GetString(string.Format("Crawler_{0}.Text", li.Text), SiteNewsHelpers.SearchableModulesResourceFile); + if (!(string.IsNullOrEmpty(caption))) + li.Text = caption; + } + + foreach (string s in SearchTypes.Split(new char[] { ',' })) + SearchTypeCheckBoxes.Items.FindByValue(s).Selected = true; + } + } + + private void UpdateBooleanSetting(string setting, bool settingValue) + { + if (Settings[setting] == null) + { + if (settingValue) + Controller.UpdateModuleSetting(ModuleId, setting, settingValue.ToString()); + } + else + { + if (settingValue) + Controller.UpdateModuleSetting(ModuleId, setting, settingValue.ToString()); + else + Controller.DeleteModuleSetting(ModuleId, setting); + } + } + + private void UpdateTextSetting(string setting, string settingValue) + { + if (Settings[setting] == null) + { + if (!(string.IsNullOrEmpty(settingValue))) + Controller.UpdateModuleSetting(ModuleId, setting, settingValue); + } + else + { + if (!(string.IsNullOrEmpty(settingValue))) + Controller.UpdateModuleSetting(ModuleId, setting, settingValue); + else + Controller.DeleteModuleSetting(ModuleId, setting); + } + } + + private void UpdateIntegerSetting(string setting, int? settingValue) + { + if (Settings[setting] == null) + { + if (settingValue != null) + { + Controller.UpdateModuleSetting(ModuleId, setting, settingValue.ToString()); + } + } + else + { + if (settingValue != null) + Controller.UpdateModuleSetting(ModuleId, setting, settingValue.ToString()); + else + Controller.DeleteModuleSetting(ModuleId, setting); + } + } + + } +} \ No newline at end of file diff --git a/Settings.ascx.designer.cs b/Settings.ascx.designer.cs new file mode 100644 index 0000000..8d39cae --- /dev/null +++ b/Settings.ascx.designer.cs @@ -0,0 +1,204 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Connect.Modules.SiteNews { + + + public partial class Settings { + + /// + /// NumberOfDaysLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl NumberOfDaysLabel; + + /// + /// NumberOfDaysRadioButtons control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList NumberOfDaysRadioButtons; + + /// + /// SearchTypesLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl SearchTypesLabel; + + /// + /// SearchTypeCheckBoxes control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBoxList SearchTypeCheckBoxes; + + /// + /// NumberOfResultsLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl NumberOfResultsLabel; + + /// + /// NumberOfResultsRadioButtons control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList NumberOfResultsRadioButtons; + + /// + /// PageSizeLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl PageSizeLabel; + + /// + /// PageSizeRadioButtons control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.RadioButtonList PageSizeRadioButtons; + + /// + /// RenderingLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label RenderingLabel; + + /// + /// IncludeSearchTypeLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeSearchTypeLabel; + + /// + /// IncludeSearchTypeCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeSearchTypeCheckBox; + + /// + /// IncludeInfoLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeInfoLabel; + + /// + /// IncludeInfoCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeInfoCheckBox; + + /// + /// IncludeDescriptionLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeDescriptionLabel; + + /// + /// IncludeDescriptionCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeDescriptionCheckBox; + + /// + /// IncludeBodyLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeBodyLabel; + + /// + /// IncludeBodyCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeBodyCheckBox; + + /// + /// IncludeAuthorLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeAuthorLabel; + + /// + /// IncludeAuthorCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeAuthorCheckBox; + + /// + /// IncludeSnippetLabel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::DotNetNuke.UI.UserControls.LabelControl IncludeSnippetLabel; + + /// + /// IncludeSnippetCheckBox control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.CheckBox IncludeSnippetCheckBox; + } +} diff --git a/SiteNews.csproj b/SiteNews.csproj new file mode 100644 index 0000000..f75d46e --- /dev/null +++ b/SiteNews.csproj @@ -0,0 +1,129 @@ + + + + + Debug + AnyCPU + + + 2.0 + {7D61A32C-0F21-453F-A981-BD8E5A3A5304} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Connect.Modules.SiteNews + DnnCSiteNews + v4.6.1 + false + + + + + + + + + + true + full + false + ..\..\..\bin\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + obj\Release\ + TRACE + prompt + 4 + false + + + + False + ..\..\..\bin\DotNetNuke.dll + + + + + + + + + + + + Settings.ascx + ASPXCodeBehind + + + Settings.ascx + + + View.ascx + ASPXCodeBehind + + + View.ascx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + False + 54045 + + + http://nine.local/DesktopModules/Connect/SiteNews + True + http://nine.local + False + False + + + False + + + + + \ No newline at end of file diff --git a/SiteNews.dnn b/SiteNews.dnn new file mode 100644 index 0000000..68823b1 --- /dev/null +++ b/SiteNews.dnn @@ -0,0 +1,138 @@ + + + + DNN-Connect SiteNews + + + + DesktopModules/Connect/images/dnn-connect-logo-32x32.png + + + + + + + + + + + + + + + + + + 07.04.02 + + + + + bin + + bin + DnnCSiteNews.dll + 01.00.00 + + + + + + DNN-Connect-SiteNews + Connect/SiteNews + Connect.Modules.SiteNews.BusinessController + + + + + + DNN-Connect SiteNews + 0 + + + + DesktopModules/Connect/SiteNews/View.ascx + False + + View + + + 0 + + + Settings + DesktopModules/Connect/SiteNews/Settings.ascx + False + DNN-Connect SiteNews Settings + Edit + + + 0 + + + + + + + DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke + UpgradeModule + + Connect.Modules.SiteNews.BusinessController + [DESKTOPMODULEID] + 01.00.00 + + + + + + DesktopModules\Connect\SiteNews + + App_LocalResources + View.ascx.resx + + + App_LocalResources + Settings.ascx.resx + + + View.ascx + + + SiteNews.dnn + + + Settings.ascx + + + + + + DesktopModules\Connect + + Documentation + DNN-Connect-SiteNews.License.txt + + + Documentation + DNN-Connect-SiteNews.ReleaseNotes.txt + + + images + dnn-connect-logo-32x32.png + + + + + + + \ No newline at end of file diff --git a/SiteNews.sln b/SiteNews.sln new file mode 100644 index 0000000..cb8a59f --- /dev/null +++ b/SiteNews.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteNews", "SiteNews.csproj", "{7D61A32C-0F21-453F-A981-BD8E5A3A5304}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D61A32C-0F21-453F-A981-BD8E5A3A5304}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D61A32C-0F21-453F-A981-BD8E5A3A5304}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D61A32C-0F21-453F-A981-BD8E5A3A5304}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D61A32C-0F21-453F-A981-BD8E5A3A5304}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/View.ascx b/View.ascx new file mode 100644 index 0000000..88cccda --- /dev/null +++ b/View.ascx @@ -0,0 +1,46 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="View.ascx.cs" Inherits="Connect.Modules.SiteNews.View" %> + + + + + + + + + + + + + +

+

+ + + + +
+ + +

+
+
+
+ + + + + + + +
\ No newline at end of file diff --git a/View.ascx.cs b/View.ascx.cs new file mode 100644 index 0000000..1fa0e13 --- /dev/null +++ b/View.ascx.cs @@ -0,0 +1,191 @@ +/* +DNN-Connect - http://dnn-connect.org +Copyright (c) 2017 +by DNN-Connect +Written by Michael Tobisch + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and +to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +*/ + +using DotNetNuke.Entities.Modules; +using DotNetNuke.Services.Exceptions; +using DotNetNuke.Services.Localization; +using DotNetNuke.Services.Search.Entities; +using DotNetNuke.Services.Search.Internals; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.UI.WebControls; + +namespace Connect.Modules.SiteNews +{ + public partial class View : PortalModuleBase + { + private SearchDataProvider _provider = null; + protected SearchDataProvider Provider + { + get + { + if (_provider == null) + _provider = new SearchDataProvider(ModuleConfiguration, UserInfo, PortalSettings); + return _provider; + } + } + + protected int FoundItems { get; set; } + +#region Settings + protected int NumberOfDays + { + get + { + object o = Settings["NumberOfDays"]; + int numberOfDays; + try + { + if (!(Int32.TryParse(o.ToString(), out numberOfDays))) + numberOfDays = 5; + } + catch (Exception) + { + numberOfDays = 5; + } + return numberOfDays; + } + } + + protected int PageSize + { + get + { + int pageSize = 5; + object o = Settings["PageSize"]; + if (o != null) + pageSize = Convert.ToInt32(o); + return pageSize; + } + } + + protected bool IncludeSearchType + { + get { return Convert.ToBoolean(Settings["IncludeSearchType"]); } + } + + protected bool IncludeInfo + { + get { return Convert.ToBoolean(Settings["IncludeInfo"]); } + } + + protected bool IncludeDescription + { + get { return Convert.ToBoolean(Settings["IncludeDescription"]); } + } + + protected bool IncludeBody + { + get { return Convert.ToBoolean(Settings["IncludeBody"]); } + } + + protected bool IncludeAuthor + { + get { return Convert.ToBoolean(Settings["IncludeAuthor"]); } + } + + protected bool IncludeSnippet + { + get { return Convert.ToBoolean(Settings["IncludeSnippet"]); } + } +#endregion + + protected void Page_PreRender(object sender, EventArgs e) + { + BindData(); + } + + protected void ResultsList_ItemDataBound(object sender, ListViewItemEventArgs e) + { + switch (e.Item.ItemType) + { + case ListViewItemType.DataItem: + SearchResult result = (SearchResult)e.Item.DataItem; + + // The Type Label is not really interesting... only for Admins/Debugging purposes + Label typeLabel = (Label)e.Item.FindControl("TypeLabel"); + typeLabel.Visible = ((IncludeSearchType) && (!(string.IsNullOrEmpty(GetSearchTypeName(result.SearchTypeId))))); + + Label descriptionLabel = (Label)e.Item.FindControl("DescriptionLabel"); + descriptionLabel.Visible = ((IncludeDescription) && (!(string.IsNullOrEmpty(result.Description)))); + + Label bodyLabel = (Label)e.Item.FindControl("BodyLabel"); + bodyLabel.Visible = ((IncludeBody) && (!(string.IsNullOrEmpty(result.Body)))); + + Label authorNameLabel = (Label)e.Item.FindControl("AuthorNameLabel"); + authorNameLabel.Visible = ((IncludeAuthor && (!string.IsNullOrEmpty(result.AuthorName)))); + + Label displayModifiedTimeLabel = (Label)e.Item.FindControl("DisplayModifiedTimeLabel"); + displayModifiedTimeLabel.Visible = (!(string.IsNullOrEmpty(result.DisplayModifiedTime))); + + Label snippetLabel = (Label)e.Item.FindControl("SnippetLabel"); + snippetLabel.Visible = ((IncludeSnippet) && (!(string.IsNullOrEmpty(result.Snippet)))); + + break; + default: + break; + } + } + + protected string GetSearchTypeName(object searchType) + { + List searchTypes = SearchHelper.Instance.GetSearchTypes().ToList(); + string searchTypeName = searchTypes.Find(s => s.SearchTypeId == (int)searchType).SearchTypeName; + string result = Localization.GetString(string.Format("Crawler_{0}.Text", searchTypeName.ToString()), SiteNewsHelpers.SearchableModulesResourceFile); + if (string.IsNullOrEmpty(result)) + result = searchTypeName; + return result; + } + + private void BindData() + { + try + { + IList searchResult = Provider.GetNewItems(); + ResultsList.DataSource = searchResult; + FoundItems = searchResult.Count; + ResultsList.DataBind(); + if (IncludeInfo) + { + ((Panel)ResultsList.FindControl("InfoPanel")).Visible = true; + ((Label)ResultsList.FindControl("FoundItems")).Text = string.Format(Localization.GetString("FoundItems.Text", LocalResourceFile), FoundItems, NumberOfDays); + } + else + { + ((Panel)ResultsList.FindControl("InfoPanel")).Visible = false; + } + ResultsPager.Visible = (FoundItems > PageSize); + } + catch (Exception exc) + { + NoNewsFoundMessagePanel.Visible = true; + Exceptions.LogException(exc); + } + } + + protected void ResultsPager_Load(object sender, EventArgs e) + { + DataPager resultsPager = (DataPager)sender; + resultsPager.PageSize = PageSize; + } + } +} \ No newline at end of file diff --git a/View.ascx.designer.cs b/View.ascx.designer.cs new file mode 100644 index 0000000..62dd190 --- /dev/null +++ b/View.ascx.designer.cs @@ -0,0 +1,60 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Connect.Modules.SiteNews { + + + public partial class View { + + /// + /// SiteSearchPanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel SiteSearchPanel; + + /// + /// NoNewsFoundMessagePanel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Panel NoNewsFoundMessagePanel; + + /// + /// NoNewsFoundMessage control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label NoNewsFoundMessage; + + /// + /// ResultsList control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ListView ResultsList; + + /// + /// ResultsPager control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.DataPager ResultsPager; + } +} diff --git a/images/dnn-connect-logo-32x32.png b/images/dnn-connect-logo-32x32.png new file mode 100644 index 0000000..5e1f15b Binary files /dev/null and b/images/dnn-connect-logo-32x32.png differ