2929using DotNetNuke . Entities . Portals ;
3030using DotNetNuke . Entities . Users ;
3131using DotNetNuke . Services . Localization ;
32- using DotNetNuke . Services . Search ;
32+ using DotNetNuke . Services . Search . Entities ;
3333using DotNetNuke . Wiki . BusinessObjects ;
3434using DotNetNuke . Wiki . BusinessObjects . Models ;
3535using System ;
3636using System . Collections ;
37+ using System . Collections . Generic ;
3738using System . IO ;
3839using System . Web ;
3940using System . Xml ;
@@ -51,90 +52,11 @@ namespace DotNetNuke.Wiki.Utilities
5152 /// populate with your own data.</para> <para>uncomment the interfaces to add the support.
5253 /// </para>
5354 /// </summary>
54- public class FeatureController : IPortable , ISearchable // , IUpgradeable
55+ public class FeatureController : ModuleSearchBase , IPortable // , IUpgradeable
5556 {
56- //// Implements IUpgradeable
57-
58- #region Variables
59-
6057 private string mSharedResourceFile =
6158 DotNetNuke . Common . Globals . ApplicationPath + "/DesktopModules/Wiki/Views/" + Localization . LocalResourceDirectory + "/" + Localization . LocalSharedResourceFile ;
6259
63- #endregion Variables
64-
65- #region Methods
66-
67- /// <summary>
68- /// Gets the search items.
69- /// </summary>
70- /// <param name="modInfo">The module information.</param>
71- /// <returns>Topics that meet the search criteria.</returns>
72- public SearchItemInfoCollection GetSearchItems ( ModuleInfo modInfo )
73- {
74- using ( UnitOfWork uOw = new UnitOfWork ( ) )
75- {
76- TopicBO topicBo = new TopicBO ( uOw ) ;
77-
78- SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection ( ) ;
79- var topics = topicBo . GetAllByModuleID ( modInfo . ModuleID ) ;
80- UserController uc = new UserController ( ) ;
81-
82- foreach ( var topic in topics )
83- {
84- SearchItemInfo searchItem = new SearchItemInfo ( ) ;
85-
86- string strContent = null ;
87- string strDescription = null ;
88- string strTitle = null ;
89- if ( ! string . IsNullOrWhiteSpace ( topic . Title ) )
90- {
91- strTitle = topic . Title ;
92- }
93- else
94- {
95- strTitle = topic . Name ;
96- }
97-
98- if ( topic . Cache != null )
99- {
100- strContent = topic . Cache ;
101- strContent += " " + topic . Keywords ;
102- strContent += " " + topic . Description ;
103-
104- strDescription = HtmlUtils . Shorten ( HtmlUtils . Clean ( HttpUtility . HtmlDecode ( topic . Cache ) , false ) , 100 ,
105- Localization . GetString ( "Dots" , this . mSharedResourceFile ) ) ;
106- }
107- else
108- {
109- strContent = topic . Content ;
110- strContent += " " + topic . Keywords ;
111- strContent += " " + topic . Description ;
112-
113- strDescription = HtmlUtils . Shorten ( HtmlUtils . Clean ( HttpUtility . HtmlDecode ( topic . Content ) , false ) , 100 ,
114- Localization . GetString ( "Dots" , this . mSharedResourceFile ) ) ;
115- }
116-
117- int userID = 0 ;
118-
119- userID = Null . NullInteger ;
120- if ( topic . UpdatedByUserID != - 9999 )
121- {
122- userID = topic . UpdatedByUserID ;
123- }
124-
125- searchItem = new SearchItemInfo ( strTitle , strDescription , userID , topic . UpdateDate , modInfo . ModuleID , topic . Name , strContent , "topic=" + WikiMarkup . EncodeTitle ( topic . Name ) ) ;
126-
127- //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription,
128- //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _
129- //// "topic=" & WikiMarkup.EncodeTitle(topic.Name))
130-
131- searchItemCollection . Add ( searchItem ) ;
132- }
133-
134- return searchItemCollection ;
135- }
136- }
137-
13860 /// <summary>
13961 /// Exports the module.
14062 /// </summary>
@@ -148,7 +70,8 @@ public string ExportModule(int moduleID)
14870 var topics = topicBo . GetAllByModuleID ( moduleID ) ;
14971
15072 ModuleController mc = new ModuleController ( ) ;
151- Hashtable settings = mc . GetModuleSettings ( moduleID ) ;
73+ var module = mc . GetModule ( moduleID ) ;
74+ Hashtable settings = module . ModuleSettings ;
15275
15376 StringWriter strXML = new StringWriter ( ) ;
15477 XmlWriter writer = new XmlTextWriter ( strXML ) ;
@@ -228,7 +151,7 @@ public void ImportModule(int moduleID, string content, string version, int userI
228151 {
229152 node = node_loopVariable ;
230153 var topic = new Topic ( ) ;
231- topic . PortalSettings = PortalController . GetCurrentPortalSettings ( ) ;
154+ topic . PortalSettings = PortalController . Instance . GetCurrentPortalSettings ( ) ;
232155 topic . AllowDiscussions = bool . Parse ( node . Attributes [ "AllowDiscussions" ] . Value ) ;
233156 topic . AllowRatings = bool . Parse ( node . Attributes [ "AllowRatings" ] . Value ) ;
234157 topic . Content = node . Attributes [ "Content" ] . Value ;
@@ -264,26 +187,74 @@ public void ImportModule(int moduleID, string content, string version, int userI
264187 System . Diagnostics . Debug . WriteLine ( ex ) ;
265188 }
266189 }
267- }
190+ }
191+
192+ public override IList < SearchDocument > GetModifiedSearchDocuments ( ModuleInfo moduleInfo , DateTime beginDateUtc )
193+ {
194+ using ( UnitOfWork uOw = new UnitOfWork ( ) )
195+ {
196+ TopicBO topicBo = new TopicBO ( uOw ) ;
197+
198+ var searchDocuments = new List < SearchDocument > ( ) ;
199+ var topics = topicBo . GetAllByModuleID ( moduleInfo . ModuleID ) ;
200+ UserController uc = new UserController ( ) ;
201+
202+ foreach ( var topic in topics )
203+ {
204+ string strContent = null ;
205+ string strDescription = null ;
206+ string strTitle = null ;
207+ if ( ! string . IsNullOrWhiteSpace ( topic . Title ) )
208+ {
209+ strTitle = topic . Title ;
210+ }
211+ else
212+ {
213+ strTitle = topic . Name ;
214+ }
268215
269- //// Public Function UpgradeModule(ByVal Version As String) As String Implements
270- //// IUpgradeable.UpgradeModule InitPermissions() Return Version End Function
216+ if ( topic . Cache != null )
217+ {
218+ strContent = topic . Cache ;
219+ strContent += " " + topic . Keywords ;
220+ strContent += " " + topic . Description ;
271221
272- //// Private Sub InitPermissions() Dim EditContent As Boolean
222+ strDescription = HtmlUtils . Shorten ( HtmlUtils . Clean ( HttpUtility . HtmlDecode ( topic . Cache ) , false ) , 100 ,
223+ Localization . GetString ( "Dots" , this . mSharedResourceFile ) ) ;
224+ }
225+ else
226+ {
227+ strContent = topic . Content ;
228+ strContent += " " + topic . Keywords ;
229+ strContent += " " + topic . Description ;
273230
274- //// Dim moduleDefId As Integer Dim pc As New PermissionController Dim permissions As
275- //// ArrayList = pc.GetPermissionByCodeAndKey("WIKI", Nothing) Dim dc As New
276- //// DesktopModuleController Dim desktopInfo As DesktopModuleInfo desktopInfo =
277- //// dc.GetDesktopModuleByModuleName("Wiki") Dim mc As New ModuleDefinitionController Dim
278- //// mInfo As ModuleDefinitionInfo mInfo =
279- //// mc.GetModuleDefinitionByName(desktopInfo.DesktopModuleID, "Wiki") moduleDefId =
280- //// mInfo.ModuleDefID For Each p As PermissionInfo In permissions If p.PermissionKey =
281- //// "EDIT_CONTENT" And p.ModuleDefID = moduleDefId Then _ EditContent = True Next If Not
282- //// EditContent Then Dim p As New PermissionInfo p.ModuleDefID = moduleDefId
283- //// p.PermissionCode
284- //// = "WIKI" p.PermissionKey = "EDIT_CONTENT" p.PermissionName = "Edit Content"
285- //// pc.AddPermission(p) End If End Sub
231+ strDescription = HtmlUtils . Shorten ( HtmlUtils . Clean ( HttpUtility . HtmlDecode ( topic . Content ) , false ) , 100 ,
232+ Localization . GetString ( "Dots" , this . mSharedResourceFile ) ) ;
233+ }
234+
235+ int userID = 0 ;
286236
287- #endregion Methods
237+ userID = Null . NullInteger ;
238+ if ( topic . UpdatedByUserID != - 9999 )
239+ {
240+ userID = topic . UpdatedByUserID ;
241+ }
242+
243+ var searchDocument = new SearchDocument
244+ {
245+ Title = strTitle ,
246+ Description = strDescription ,
247+ AuthorUserId = userID ,
248+ ModifiedTimeUtc = topic . UpdateDate . ToUniversalTime ( ) ,
249+ ModuleId = moduleInfo . ModuleID ,
250+ UniqueKey = $ "wikitopic={ WikiMarkup . EncodeTitle ( topic . Name ) } ",
251+ Body = strContent ,
252+ } ;
253+ searchDocuments . Add ( searchDocument ) ;
254+ }
255+
256+ return searchDocuments ;
257+ }
258+ }
288259 }
289260}
0 commit comments