public void AddAnnouncementToJournal(AnnouncementInfo announcement, String journalType, ModuleInfo moduleInfo) { var objJournalType = JournalController.Instance.GetJournalType(journalType); var journalItem = new JournalItem { PortalId = announcement.PortalID, ProfileId = announcement.LastModifiedByUserID, UserId = announcement.LastModifiedByUserID, ContentItemId = announcement.ContentItemID, Title = announcement.Title }; var data = new ItemData { Url = announcement.Permalink() }; journalItem.ItemData = data; journalItem.Summary = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "..."); journalItem.Body = announcement.Description; journalItem.JournalTypeId = objJournalType.JournalTypeId; journalItem.SecuritySet = "E,"; JournalController.Instance.SaveJournalItem(journalItem, moduleInfo); }
/// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { Hashtable moduleSettings = Entities.Portals.PortalSettings.GetModuleSettings(ModInfo.ModuleID); int descriptionLength = 100; if (Convert.ToString(moduleSettings["descriptionLength"]) != "") { descriptionLength = int.Parse(Convert.ToString(moduleSettings["descriptionLength"])); if (descriptionLength < 1) { descriptionLength = 1950; //max length of description is 2000 char, take a bit less to make sure it fits... } } var searchItemCollection = new SearchItemInfoCollection(); IEnumerable <AnnouncementInfo> announcements = GetCurrentAnnouncements(ModInfo.ModuleID, Null.NullDate); foreach (AnnouncementInfo objAnnouncement in announcements) { var tempVar = objAnnouncement; string strContent = System.Web.HttpUtility.HtmlDecode(tempVar.Title + " " + tempVar.Description); string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(tempVar.Description), false), descriptionLength, "..."); var searchItem = new SearchItemInfo(ModInfo.ModuleTitle + " - " + tempVar.Title, strDescription, tempVar.CreatedByUserID, tempVar.PublishDate.Value, ModInfo.ModuleID, tempVar.ItemID.ToString(CultureInfo.InvariantCulture), strContent, "ItemID=" + tempVar.ItemID.ToString(CultureInfo.InvariantCulture)); searchItemCollection.Add(searchItem); } return(searchItemCollection); }
/// ----------------------------------------------------------------------------- /// <summary> /// GetSearchItems implements the ISearchable Interface /// </summary> /// <remarks> /// </remarks> /// <param name = "ModInfo">The ModuleInfo for the module to be Indexed</param> /// <history> /// </history> /// ----------------------------------------------------------------------------- public SearchItemInfoCollection GetSearchItems(ModuleInfo ModInfo) { var objWorkflow = new WorkflowStateController(); int WorkflowID = GetWorkflow(ModInfo.ModuleID, ModInfo.TabID, ModInfo.PortalID).Value; var SearchItemCollection = new SearchItemInfoCollection(); HtmlTextInfo objContent = GetTopHtmlText(ModInfo.ModuleID, true, WorkflowID); if (objContent != null) { //content is encoded in the Database so Decode before Indexing string strContent = HttpUtility.HtmlDecode(objContent.Content); //Get the description string string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), MAX_DESCRIPTION_LENGTH, "..."); var SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, strDescription, objContent.LastModifiedByUserID, objContent.LastModifiedOnDate, ModInfo.ModuleID, "", strContent, "", Null.NullInteger); SearchItemCollection.Add(SearchItem); } return(SearchItemCollection); }
private static SearchDocument GetTabSearchDocument(Data.Entities.Pages tab, TabInfo tabInfo) { List <Localization> Localization = Managers.LocalizationManager.GetLocaleProperties(tab.Locale, "Page", tab.TabID, null); SearchDocument searchDoc = new SearchDocument { SearchTypeId = TabSearchTypeId, UniqueKey = TabMetaDataPrefixTag + tab.TabID, TabId = tab.TabID, PortalId = tab.PortalID, CultureCode = tab.Locale, ModifiedTimeUtc = tab.UpdatedOn.Value, Body = HtmlUtils.Clean(tab.Content, false), Description = GetDescription(tabInfo, Localization) }; searchDoc.Keywords.Add("keywords", tabInfo.KeyWords); //Using TabName for searchDoc.Title due to higher prevalence and relavency || TabTitle will be stored as a keyword searchDoc.Title = GetName(tabInfo, Localization); searchDoc.Keywords.Add("title", GetTitle(tabInfo, Localization)); if (tabInfo.Terms != null && tabInfo.Terms.Count > 0) { searchDoc.Tags = tabInfo.Terms.Select(t => t.Name); } if (Logger.IsTraceEnabled) { Logger.Trace("TabIndexer: Search document for metaData added for page [" + GetTitle(tabInfo, Localization) + " tid:" + tab.TabID + " pid:" + tab.ID + "]"); } return(searchDoc); }
/// <summary> /// Implementation of ModuleSearchBase /// </summary> /// <param name="moduleInfo">Module Information</param> /// <param name="beginDateUtc">Date of the search indexer run</param> /// <returns>IList of SearchDocument</returns> public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc) { DotNetNuke.Services.Search.Internals.InternalSearchController.Instance.DeleteSearchDocumentsByModule(moduleInfo.PortalID, moduleInfo.ModuleID, moduleInfo.ModuleDefID); var searchDocuments = new List <SearchDocument>(); var helpers = new Helpers(); var repositoryObjects = GetRepositoryObjects(moduleInfo.ModuleID, "", "Name", helpers.IS_APPROVED, -1, "", -1); foreach (RepositoryInfo repObject in repositoryObjects) { int userId = -1; int.TryParse(repObject.CreatedByUser, out userId); var searchDoc = new SearchDocument { UniqueKey = moduleInfo.ModuleID.ToString(), PortalId = moduleInfo.PortalID, Title = moduleInfo.ModuleTitle + " - " + repObject.Name, Description = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(repObject.Description), false), 100, "..."), Body = repObject.Description, ModifiedTimeUtc = repObject.UpdatedDate }; searchDocuments.Add(searchDoc); } return(searchDocuments); }
protected static string GetDescription(object description) { if (description != null) { return(HtmlUtils.Shorten(HtmlUtils.Clean(description.ToString(), true), 200, string.Empty) + " "); } return(string.Empty); }
protected void lvVersions_ItemDataBound(object sender, System.Web.UI.WebControls.ListViewItemEventArgs e) { if (e.Item.ItemType == ListViewItemType.DataItem) { HtmlTextInfo htmlText = (HtmlTextInfo)e.Item.DataItem; Literal litVersion = (Literal)e.Item.FindControl("litVersion"); Literal litDate = (Literal)e.Item.FindControl("litDate"); Literal litTitle = (Literal)e.Item.FindControl("litTitle"); Literal litContent = (Literal)e.Item.FindControl("litContent"); Literal litDisplayName = (Literal)e.Item.FindControl("litDisplayName"); Literal litPublished = (Literal)e.Item.FindControl("litPublished"); ImageButton btnRemove = (ImageButton)e.Item.FindControl("btnRemove"); ImageButton btnPreview = (ImageButton)e.Item.FindControl("btnPreview"); ImageButton btnRollback = (ImageButton)e.Item.FindControl("btnRollback"); litVersion.Text = htmlText.Version.ToString(); DateTime lastModifiedDate = htmlText.LastModifiedOnDate > htmlText.CreatedOnDate ? htmlText.LastModifiedOnDate : htmlText.CreatedOnDate; litDate.Text = lastModifiedDate.ToString("dd/MM/yyyy hh:mm:ss"); litTitle.Text = htmlText.ModuleTitle; litContent.Text = HtmlUtils.Shorten(HtmlUtils.Clean(htmlText.Content, false), 80, "..."); int lastModifiedBy = htmlText.LastModifiedOnDate > htmlText.CreatedOnDate ? htmlText.LastModifiedByUserId : htmlText.CreatedByUserID; var objUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, lastModifiedBy); litDisplayName.Text = objUser != null ? objUser.DisplayName : "Default"; litPublished.Text = htmlText.IsPublished.ToString(); //set command args btnRemove.CommandArgument = htmlText.ItemId.ToString(); btnPreview.CommandArgument = htmlText.ItemId.ToString(); btnRollback.CommandArgument = htmlText.ItemId.ToString(); //hide remove button for Non-Admin string deleteMsg = Localization.GetString("DeleteVersion.Confirm", LocalResourceFile) .Replace("[VERSION]", htmlText.Version.ToString()) .Replace("[LOCALE]", htmlText.Locale); btnRemove.OnClientClick = "return confirm(\"" + deleteMsg + "\");"; btnRemove.Visible = (UserInfo.IsSuperUser || PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName)); //hide rollback button for current active item if (_topHtmlTextItemId == -1) { var item = _htmlTextController.GetTopHtmlText(ModuleId, ddlLocale.SelectedValue, true); if (item != null) { _topHtmlTextItemId = item.ItemId; } } string rollbackMsg = Localization.GetString("RollbackVersion.Confirm", LocalResourceFile) .Replace("[VERSION]", htmlText.Version.ToString()) .Replace("[LOCALE]", htmlText.Locale); btnRollback.OnClientClick = "return confirm(\"" + rollbackMsg + "\");"; btnRollback.Visible = (htmlText.ItemId != _topHtmlTextItemId); } }
/// <summary> /// Gets a collection of <see cref="SearchItemInfo"/> instances, describing the job openings that can be viewed in the given Job Details module. /// </summary> /// <param name="modInfo">Information about the module instance for which jobs should be returned.</param> /// <returns>A collection of <see cref="SearchItemInfo"/> instances</returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { if (modInfo == null) { throw new ArgumentNullException("modInfo", @"modInfo must not be null."); } var searchItems = new SearchItemInfoCollection(); // only index the JobDetail module definition (since most of this information is only viewable there, // and because the Guid parameter on the SearchItemInfo ("jobid=" + jobid) gets put on the querystring to make it work all automagically). BD if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName(ModuleDefinition.JobDetail.ToString(), modInfo.DesktopModuleID).ModuleDefID == modInfo.ModuleDefID && ModuleSettings.JobDetailEnableDnnSearch.GetValueAsBooleanFor(DesktopModuleName, modInfo, ModuleSettings.JobDetailEnableDnnSearch.DefaultValue)) { int?jobGroupId = ModuleSettings.JobGroupId.GetValueAsInt32For(DesktopModuleName, modInfo, ModuleSettings.JobGroupId.DefaultValue); using (IDataReader jobs = DataProvider.Instance().GetJobs(jobGroupId, modInfo.PortalID)) { while (jobs.Read()) { if (!(bool)jobs["IsFilled"]) { string jobId = ((int)jobs["JobId"]).ToString(CultureInfo.InvariantCulture); string searchDescription = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean((string)jobs["JobDescription"], false), true); string searchItemTitle = string.Format( CultureInfo.CurrentCulture, Utility.GetString("JobInLocation", LocalResourceFile, modInfo.PortalID), (string)jobs["JobTitle"], (string)jobs["LocationName"], (string)jobs["StateName"]); string searchedContent = HtmlUtils.StripWhiteSpace( HtmlUtils.Clean( (string)jobs["JobTitle"] + " " + (string)jobs["JobDescription"] + " " + (string)jobs["RequiredQualifications"] + " " + (string)jobs["DesiredQualifications"], false), true); searchItems.Add( new SearchItemInfo( searchItemTitle, searchDescription, (int)jobs["RevisingUser"], (DateTime)jobs["RevisionDate"], modInfo.ModuleID, jobId, searchedContent, "jobid=" + jobId)); } } } } return(searchItems); }
private void BindCleanableItems() { cleanableListBox.Items.Clear(); foreach (var htmlText in GetCleanableHtmlTexts()) { string text = HtmlUtils.Clean(htmlText.ModuleTitle + " - " + htmlText.Content, false); var item = new ListItem(string.Format("{0} ({1}) - {2}", HtmlUtils.Shorten(text, 35, "..."), htmlText.Locale, htmlText.LastModifiedOnDate), htmlText.ItemId.ToString()); cleanableListBox.Items.Add(item); } }
protected string GetItemDescription(object row) { if (row != null) { var view = (DataRowView)row; string description; if (TypeOfItem == ItemType.Article) { Article a = Article.GetArticleVersion(Convert.ToInt32(view["ItemVersionId"], CultureInfo.InvariantCulture), PortalId); description = HtmlUtils.Shorten(HtmlUtils.Clean(a.VersionDescription, true), 200, string.Empty) + " "; } else { description = HtmlUtils.Shorten(HtmlUtils.Clean(view["Description"].ToString(), true), 200, string.Empty) + " "; } return(description); } return(""); }
// feel free to remove any interfaces that you don't wish to use // (requires that you also update the .dnn manifest file) #region Optional Interfaces /// <summary> /// Gets the modified search documents for the DNN search engine indexer. /// </summary> /// <param name="moduleInfo">The module information.</param> /// <param name="beginDate">The begin date.</param> /// <returns></returns> public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDate) { var searchDocuments = new List <SearchDocument>(); var controller = new HtmlTextController(); var items = controller.GetHtmlTextList(moduleInfo.ModuleID); var repo = new HtmlModuleSettingsRepository(); var settings = repo.GetSettings(moduleInfo); foreach (var item in items) { if (item.LastModifiedOnDate.ToUniversalTime() <= beginDate.ToUniversalTime() || item.LastModifiedOnDate.ToUniversalTime() >= DateTime.UtcNow) { continue; } // Get the content & summary var strContent = HtmlUtils.Clean(string.Format("{0}<br />{1}", item.Content, item.Summary), false); // Get the description string var description = strContent.Length <= settings.SearchDescLength ? strContent : HtmlUtils.Shorten(strContent, settings.SearchDescLength, "..."); var searchDocumnet = new SearchDocument { UniqueKey = string.Format("Items:{0}:{1}", moduleInfo.ModuleID, item.ItemId), // any unique identifier to be able to query for your individual record PortalId = moduleInfo.PortalID, // the PortalID TabId = moduleInfo.TabID, // the TabID AuthorUserId = item.LastModifiedByUserId, // the person who created the content Title = moduleInfo.ModuleTitle, // the title of the content, but should be the module title Description = description, // the description or summary of the content Body = strContent, // the long form of your content ModifiedTimeUtc = item.LastModifiedOnDate.ToUniversalTime(), // a time stamp for the search results page CultureCode = moduleInfo.CultureCode, // the current culture code IsActive = true // allows you to remove the item from the search index (great for soft deletes) }; searchDocuments.Add(searchDocumnet); } return(searchDocuments); }
public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo) { SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection(); LocaleCollection lCollection = Localization.GetEnabledLocales(); foreach (Locale localeInfo in lCollection) { effority.Ealo.StringInfo objText; effority.Ealo.StringInfo objSummary; objText = effority.Ealo.Controller.GetStringByQualifierAndStringName(Consts.DesktopHTMLQualifier, ModInfo.ModuleID.ToString(), localeInfo.Code, true); objSummary = effority.Ealo.Controller.GetStringByQualifierAndStringName(Consts.DesktopSummaryQualifier, ModInfo.ModuleID.ToString(), localeInfo.Code, true); if (!objText.StringTextIsNull) { string strDesktopHtml = HttpUtility.HtmlDecode(objText.StringText); string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strDesktopHtml, false), MAX_DESCRIPTION_LENGTH, "..."); SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, localeInfo.Text + " - " + strDescription, -1, DateTime.Now, ModInfo.ModuleID, "", objSummary.StringText + " " + strDesktopHtml, "", Null.NullInteger); SearchItemCollection.Add(SearchItem); } } return(SearchItemCollection); }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { var workflowId = GetWorkflow(modInfo.ModuleID, modInfo.TabID, modInfo.PortalID).Value; var searchDocuments = new List <SearchDocument>(); var htmlTextInfo = GetTopHtmlText(modInfo.ModuleID, true, workflowId); if (htmlTextInfo != null && (htmlTextInfo.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && htmlTextInfo.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow)) { var strContent = HtmlUtils.Clean(htmlTextInfo.Content, false); // Get the description string int maxLength; if (!Int32.TryParse((string)modInfo.ModuleSettings["HtmlText_SearchDescLength"], out maxLength)) { maxLength = MAX_DESCRIPTION_LENGTH; } var description = strContent.Length <= maxLength ? strContent : HtmlUtils.Shorten(strContent, maxLength, "..."); var searchDoc = new SearchDocument { UniqueKey = modInfo.ModuleID.ToString(), PortalId = modInfo.PortalID, Title = modInfo.ModuleTitle, Description = description, Body = strContent, ModifiedTimeUtc = htmlTextInfo.LastModifiedOnDate.ToUniversalTime() }; if (modInfo.Terms != null && modInfo.Terms.Count > 0) { searchDoc.Tags = CollectHierarchicalTags(modInfo.Terms); } searchDocuments.Add(searchDoc); } return(searchDocuments); }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { var workflowId = this.GetWorkflow(modInfo.ModuleID, modInfo.TabID, modInfo.PortalID).Value; var searchDocuments = new List <SearchDocument>(); var htmlTextInfo = this.GetTopHtmlText(modInfo.ModuleID, true, workflowId); var repo = new HtmlModuleSettingsRepository(); var settings = repo.GetSettings(modInfo); if (htmlTextInfo != null && (htmlTextInfo.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && htmlTextInfo.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow)) { var strContent = HtmlUtils.Clean(htmlTextInfo.Content, false); // Get the description string var description = strContent.Length <= settings.SearchDescLength ? strContent : HtmlUtils.Shorten(strContent, settings.SearchDescLength, "..."); var searchDoc = new SearchDocument { UniqueKey = modInfo.ModuleID.ToString(), PortalId = modInfo.PortalID, Title = modInfo.ModuleTitle, Description = description, Body = strContent, ModifiedTimeUtc = htmlTextInfo.LastModifiedOnDate.ToUniversalTime(), }; if (modInfo.Terms != null && modInfo.Terms.Count > 0) { searchDoc.Tags = CollectHierarchicalTags(modInfo.Terms); } searchDocuments.Add(searchDoc); } return(searchDocuments); }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDate) { var searchDocuments = new List <SearchDocument>(); var FAQs = ListFAQ(Convert.ToInt32(modInfo.ModuleID), 0, true); foreach (object objFaq in FAQs) { var faq = ((FAQsInfo)objFaq); if (faq.FaqHide) { continue; } // Remove all HTML overhead from the content string strContent = HtmlUtils.Clean(faq.Answer, false); // And create an entry that will fit string strDescription = HtmlUtils.Clean(faq.Question, false); strDescription = strDescription.Length <= MAX_DESCRIPTION_LENGTH ? strDescription : HtmlUtils.Shorten(strDescription, 100, "..."); var searchDoc = new SearchDocument { UniqueKey = String.Format("faqid={0}", faq.ItemID), PortalId = modInfo.PortalID, Title = modInfo.ModuleTitle, Description = strDescription, Body = strContent, ModifiedTimeUtc = DateTime.Now.ToUniversalTime() // faq.DateModified.ToUniversalTime() }; searchDocuments.Add(searchDoc); } return(searchDocuments); }
/// <inheritdoc /> public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc) { if (moduleInfo == null) { throw new ArgumentNullException("modInfo", @"modInfo must not be null."); } var searchItems = new List <SearchDocument>(); // only index the JobDetail module definition (since most of this information is only viewable there, // and because the Guid parameter on the SearchItemInfo ("jobid=" + jobid) gets put on the querystring to make it work all automagically). BD if (ModuleDefinitionController.GetModuleDefinitionByFriendlyName( ModuleDefinition.JobDetail.ToString(), moduleInfo.DesktopModuleID) .ModuleDefID != moduleInfo.ModuleDefID || !ModuleSettings.JobDetailEnableDnnSearch.GetValueAsBooleanFor( DesktopModuleName, moduleInfo, ModuleSettings.JobDetailEnableDnnSearch.DefaultValue)) { return(searchItems); } int?jobGroupId = ModuleSettings.JobGroupId.GetValueAsInt32For( DesktopModuleName, moduleInfo, ModuleSettings.JobGroupId.DefaultValue); // TODO: only retrieve jobs modified after beginDateUtc using (IDataReader jobs = DataProvider.Instance() .GetJobs(jobGroupId, moduleInfo.PortalID)) { while (jobs.Read()) { var jobId = ((int)jobs["JobId"]).ToString(CultureInfo.InvariantCulture); var revisionDate = (DateTime)jobs["RevisionDate"]; var searchDocument = new SearchDocument { UniqueKey = "Employment_Job_" + jobId, ModifiedTimeUtc = revisionDate.ToUniversalTime(), ModuleId = moduleInfo.ModuleID, PortalId = moduleInfo.PortalID, QueryString = "jobid=" + jobId, }; searchItems.Add(searchDocument); if ((bool)jobs["IsFilled"]) { searchDocument.IsActive = false; continue; } var searchDescription = HtmlUtils.StripWhiteSpace( HtmlUtils.Clean((string)jobs["JobDescription"], false), true); var searchItemTitle = string.Format( CultureInfo.CurrentCulture, Utility.GetString("JobInLocation", LocalResourceFile, moduleInfo.PortalID), (string)jobs["JobTitle"], (string)jobs["LocationName"], (string)jobs["StateName"]); var searchedContent = HtmlUtils.StripWhiteSpace( HtmlUtils.Clean( (string)jobs["JobTitle"] + " " + (string)jobs["JobDescription"] + " " + (string)jobs["RequiredQualifications"] + " " + (string)jobs["DesiredQualifications"], false), true); searchDocument.Title = searchItemTitle; searchDocument.Description = searchDescription; searchDocument.AuthorUserId = (int)jobs["RevisingUser"]; searchDocument.Body = searchedContent; } } return(searchItems); }
/// <summary> /// Gets the search items. /// </summary> /// <param name="modInfo">The module information.</param> /// <returns>Topics that meet the search criteria.</returns> public SearchItemInfoCollection GetSearchItems(ModuleInfo modInfo) { using (UnitOfWork uOw = new UnitOfWork()) { TopicBO topicBo = new TopicBO(uOw); SearchItemInfoCollection searchItemCollection = new SearchItemInfoCollection(); var topics = topicBo.GetAllByModuleID(modInfo.ModuleID); UserController uc = new UserController(); foreach (var topic in topics) { SearchItemInfo searchItem = new SearchItemInfo(); string strContent = null; string strDescription = null; string strTitle = null; if (!string.IsNullOrWhiteSpace(topic.Title)) { strTitle = topic.Title; } else { strTitle = topic.Name; } if (topic.Cache != null) { strContent = topic.Cache; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Cache), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } else { strContent = topic.Content; strContent += " " + topic.Keywords; strContent += " " + topic.Description; strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(HttpUtility.HtmlDecode(topic.Content), false), 100, Localization.GetString("Dots", this.mSharedResourceFile)); } int userID = 0; userID = Null.NullInteger; if (topic.UpdatedByUserID != -9999) { userID = topic.UpdatedByUserID; } searchItem = new SearchItemInfo(strTitle, strDescription, userID, topic.UpdateDate, modInfo.ModuleID, topic.Name, strContent, "topic=" + WikiMarkup.EncodeTitle(topic.Name)); //// New SearchItemInfo(ModInfo.ModuleTitle & "-" & strTitle, strDescription, //// userID, topic.UpdateDate, ModInfo.ModuleID, topic.Name, strContent, _ //// "topic=" & WikiMarkup.EncodeTitle(topic.Name)) searchItemCollection.Add(searchItem); } return(searchItemCollection); } }
private static bool TextEditorHasValue(string value) { return(Engage.Utility.HasValue(HtmlUtils.Clean(value, false))); }
private void BindData() { int itemId = Convert.ToInt32(this.cboItemType.SelectedValue, CultureInfo.InvariantCulture); if (this.CategoryId > -1) { // user clicked on a subcategory. itemId = this.CategoryId; } // set the approval status ID to approved by default, if we're using approvals look for the selected value int approvalStatusId = ApprovalStatus.Approved.GetId(); if (this.UseApprovals) { approvalStatusId = Convert.ToInt32(this.cboWorkflow.SelectedValue, CultureInfo.InvariantCulture); } var qsp = new QueryStringParameters(); DataSet ds; if (this.txtArticleSearch.Text.Trim() != string.Empty) { var objSecurity = new PortalSecurity(); string searchKey = objSecurity.InputFilter(this.txtArticleSearch.Text.Trim(), PortalSecurity.FilterFlag.NoSQL); ds = itemId == -1 ? DataProvider.Instance().GetAdminItemListingSearchKey( TopLevelCategoryItemType.Category.GetId(), ItemType.Category.GetId(), RelationshipType.CategoryToTopLevelCategory.GetId(), RelationshipType.ItemToRelatedCategory.GetId(), approvalStatusId, " vi.createddate desc ", searchKey, this.PortalId) : DataProvider.Instance().GetAdminItemListingSearchKey( itemId, ItemType.Category.GetId(), RelationshipType.ItemToParentCategory.GetId(), RelationshipType.ItemToRelatedCategory.GetId(), approvalStatusId, " vi.createddate desc ", searchKey, this.PortalId); } else { ds = itemId == -1 ? DataProvider.Instance().GetAdminItemListing( TopLevelCategoryItemType.Category.GetId(), ItemType.Category.GetId(), RelationshipType.CategoryToTopLevelCategory.GetId(), approvalStatusId, this.PortalId) : DataProvider.Instance().GetAdminItemListing( itemId, ItemType.Category.GetId(), RelationshipType.ItemToParentCategory.GetId(), RelationshipType.ItemToRelatedCategory.GetId(), approvalStatusId, this.PortalId); } DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { var t = new Table { Width = Unit.Percentage(100), CssClass = "Normal", CellPadding = 4, CellSpacing = 0, GridLines = GridLines.Horizontal, BorderColor = Color.Gray, BorderStyle = BorderStyle.Solid, BorderWidth = Unit.Pixel(1) }; var row = new TableRow { CssClass = "listing_table_head_row" }; t.Rows.Add(row); var cell = new TableCell(); row.Cells.Add(cell); cell.Text = Localization.GetString("ID", this.LocalResourceFile); cell = new TableCell(); row.Cells.Add(cell); cell.Text = Localization.GetString("Name", this.LocalResourceFile); cell = new TableCell(); row.Cells.Add(cell); cell.Text = Localization.GetString("Description", this.LocalResourceFile); cell = new TableCell(); row.Cells.Add(cell); cell.Text = " "; cell = new TableCell(); row.Cells.Add(cell); cell.Text = " "; cell = new TableCell(); row.Cells.Add(cell); cell.Text = " "; cell = new TableCell(); row.Cells.Add(cell); cell.Text = " "; cell = new TableCell(); row.Cells.Add(cell); cell.Text = " "; for (int i = 0; i < dt.Rows.Count; i++) { DataRow r = dt.Rows[i]; row = new TableRow { CssClass = i % 2 == 0 ? "adminItemSearchDarkRow" : "adminItemSearchLightRow", VerticalAlign = VerticalAlign.Top }; t.Rows.Add(row); cell = new TableCell(); row.Cells.Add(cell); cell.Text = r["ItemID"].ToString(); cell = new TableCell(); row.Cells.Add(cell); cell.Text = r["Name"].ToString(); cell = new TableCell(); row.Cells.Add(cell); cell.Text = HtmlUtils.Shorten(HtmlUtils.Clean(r["Description"].ToString(), true), 200, string.Empty) + " "; cell = new TableCell(); row.Cells.Add(cell); // check if the category has any sub categories, if not don't display link var hl = new HyperLink(); if (Convert.ToInt32(r["ChildCount"], CultureInfo.InvariantCulture) > 0) { cell.Controls.Add(hl); qsp.ClearKeys(); qsp.Add("ctl", Utility.AdminContainer); qsp.Add("mid", this.ModuleId.ToString(CultureInfo.InvariantCulture)); qsp.Add("adminType", "categorylist"); qsp.Add("itemId", r["ItemId"]); // qsp.Add("category", r["Name"]); qsp.Add("parentId", itemId); if (this.TopLevelId == -1) { qsp.Add("topLevelId", this.cboItemType.SelectedValue); } else { qsp.Add("topLevelId", this.TopLevelId); } hl.NavigateUrl = this.BuildLinkUrl(qsp.ToString()); hl.Text = Localization.GetString("SubCategories", this.LocalResourceFile); } else { var l1 = new Label { Text = " <br /> " }; cell.Controls.Add(l1); } // Add the CategorySort link cell = new TableCell(); row.Cells.Add(cell); hl = new HyperLink(); cell.Controls.Add(hl); qsp.ClearKeys(); qsp.Add("ctl", Utility.AdminContainer); qsp.Add("mid", this.ModuleId.ToString(CultureInfo.InvariantCulture)); qsp.Add("adminType", "categorysort"); qsp.Add("itemid", r["ItemId"]); hl.NavigateUrl = this.BuildLinkUrl(qsp.ToString()); hl.Text = Localization.GetString("CategorySort", this.LocalResourceFile); cell = new TableCell(); row.Cells.Add(cell); cell = new TableCell(); row.Cells.Add(cell); hl = new HyperLink(); cell.Controls.Add(hl); qsp.ClearKeys(); qsp.Add("ctl", Utility.AdminContainer); qsp.Add("mid", this.ModuleId.ToString(CultureInfo.InvariantCulture)); qsp.Add("adminType", "versionslist"); qsp.Add("itemid", r["ItemId"]); hl.NavigateUrl = this.BuildLinkUrl(qsp.ToString()); hl.Text = Localization.GetString("Versions", this.LocalSharedResourceFile); cell = new TableCell(); row.Cells.Add(cell); hl = new HyperLink(); cell.Controls.Add(hl); qsp.ClearKeys(); qsp.Add("ctl", Utility.AdminContainer); qsp.Add("mid", this.ModuleId.ToString(CultureInfo.InvariantCulture)); qsp.Add("adminType", "categoryEdit"); qsp.Add("versionid", r["ItemVersionId"]); // qsp.Add("modid", r["ModuleId"]); qsp.Add("parentId", itemId); if (this.TopLevelId == -1) { qsp.Add("topLevelId", this.cboItemType.SelectedValue); } else { qsp.Add("topLevelId", this.TopLevelId); } hl.NavigateUrl = this.BuildLinkUrl(qsp.ToString()); hl.Text = Localization.GetString("Edit", this.LocalResourceFile); } this.phList.Controls.Add(t); if (!this.cboItemType.SelectedValue.Equals("-1")) { this.lblMessage.Text = Localization.GetString("SubCategoriesFor", this.LocalResourceFile) + " " + this.cboItemType.SelectedItem; } } else { if (!this.cboItemType.SelectedValue.Equals("-1")) { this.lblMessage.Text = Localization.GetString("NoSubcategoriesFor", this.LocalResourceFile) + " " + this.cboItemType.SelectedItem; } } }
/// <summary> /// AddIndexWords adds the Index Words to the Data Store /// </summary> /// <param name="indexId">The Id of the SearchItem</param> /// <param name="searchItem">The SearchItem</param> /// <param name="language">The Language of the current Item</param> /// <history> /// [cnurse] 11/15/2004 documented /// [cnurse] 11/16/2004 replaced calls to separate content clean-up /// functions with new call to HtmlUtils.Clean(). /// replaced logic to determine whether word should /// be indexed by call to CanIndexWord() /// </history> private void AddIndexWords(int indexId, SearchItemInfo searchItem, string language) { Hashtable IndexWords = new Hashtable(); Hashtable IndexPositions = new Hashtable(); //Get the Settings for this Module _settings = SearchDataStoreController.GetSearchSettings(searchItem.ModuleId); if (_settings == null) { //Try Host Settings _settings = Globals.HostSettings; } string setting = GetSetting("MaxSearchWordLength"); if (!String.IsNullOrEmpty(setting)) { maxWordLength = int.Parse(setting); } setting = GetSetting("MinSearchWordLength"); if (!String.IsNullOrEmpty(setting)) { minWordLength = int.Parse(setting); } setting = GetSetting("SearchIncludeCommon"); if (setting == "Y") { includeCommon = true; } setting = GetSetting("SearchIncludeNumeric"); if (setting == "N") { includeNumbers = false; } string Content = searchItem.Content; // clean content Content = HtmlUtils.Clean(Content, true); Content = Content.ToLower(); //' split content into words string[] ContentWords = Content.Split(' '); // process each word int intWord = 0; string strWord; foreach (string tempLoopVar_strWord in ContentWords) { strWord = tempLoopVar_strWord; if (CanIndexWord(strWord, language)) { intWord++; if (IndexWords.ContainsKey(strWord) == false) { IndexWords.Add(strWord, 0); IndexPositions.Add(strWord, 1); } // track number of occurrences of word in content IndexWords[strWord] = Convert.ToInt32(IndexWords[strWord]) + 1; // track positions of word in content IndexPositions[strWord] = Convert.ToString(IndexPositions[strWord]) + "," + intWord.ToString(); } } // get list of words ( non-common ) Hashtable Words = GetSearchWords(); // this could be cached int WordId; //' iterate through each indexed word object objWord; foreach (object tempLoopVar_objWord in IndexWords.Keys) { objWord = tempLoopVar_objWord; strWord = Convert.ToString(objWord); if (Words.ContainsKey(strWord)) { // word is in the DataStore WordId = Convert.ToInt32(Words[strWord]); } else { // add the word to the DataStore WordId = DataProvider.Instance().AddSearchWord(strWord); Words.Add(strWord, WordId); } // add the indexword int SearchItemWordID = DataProvider.Instance().AddSearchItemWord(indexId, WordId, Convert.ToInt32(IndexWords[strWord])); DataProvider.Instance().AddSearchItemWordPosition(SearchItemWordID, Convert.ToString(IndexPositions[strWord])); } }
/// <summary> /// Gets the search items for the module's articles. /// </summary> /// <returns>The collection of search items for the <see cref="Module"/>'s articles</returns> private IEnumerable <SearchItemInfo> GetSearchItemsImpl() { var articlesTable = Article.GetArticlesByModuleId(this.Module.ModuleID, true); foreach (DataRow row in articlesTable.Rows) { var searchedContent = new StringBuilder(8192); // article name string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false); if (Engage.Utility.HasValue(name)) { searchedContent.AppendFormat("{0}{1}", name, " "); } else { // do we bother with the rest? continue; } // article text string articleText = row["ArticleText"].ToString().Trim(); if (Engage.Utility.HasValue(articleText)) { searchedContent.AppendFormat("{0}{1}", articleText, " "); } // article description string description = row["Description"].ToString().Trim(); if (Engage.Utility.HasValue(description)) { searchedContent.AppendFormat("{0}{1}", description, " "); } // article metakeyword string keyword = row["MetaKeywords"].ToString().Trim(); if (Engage.Utility.HasValue(keyword)) { searchedContent.AppendFormat("{0}{1}", keyword, " "); } // article metadescription string metaDescription = row["MetaDescription"].ToString().Trim(); if (Engage.Utility.HasValue(metaDescription)) { searchedContent.AppendFormat("{0}{1}", metaDescription, " "); } // article metatitle string metaTitle = row["MetaTitle"].ToString().Trim(); if (Engage.Utility.HasValue(metaTitle)) { searchedContent.AppendFormat("{0}{1}", metaTitle, " "); } string itemId = row["ItemId"].ToString(); var item = new SearchItemInfo { Title = name, Description = HtmlUtils.Clean(description, false), Author = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture), PubDate = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture), ModuleId = this.Module.ModuleID, SearchKey = "Article-" + itemId, Content = HtmlUtils.StripWhiteSpace(HtmlUtils.Clean(searchedContent.ToString(), false), true), }; if (this.SetGuid) { item.GUID = "itemid=" + itemId; } if (ModuleBase.AllowVenexusSearchForPortal(this.Module.PortalID)) { string indexUrl = UrlGenerator.GetItemLinkUrl( Convert.ToInt32(itemId, CultureInfo.InvariantCulture), Utility.GetPortalSettings(this.Module.PortalID), this.Module.TabID, this.Module.ModuleID); // UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent) DataProvider.Instance().UpdateVenexusBraindump( Convert.ToInt32(itemId, CultureInfo.InvariantCulture), name, articleText, HtmlUtils.Clean(articleText, false), this.Module.PortalID, indexUrl); } yield return(item); } }
private String DoProductIdx(DotNetNuke.Entities.Portals.PortalInfo portal, DateTime lastrun, Boolean debug) { if (debug) { InternalSearchController.Instance.DeleteAllDocuments(portal.PortalID, SearchHelper.Instance.GetSearchTypeByName("tab").SearchTypeId); } var searchDocs = new List <SearchDocument>(); var culturecodeList = DnnUtils.GetCultureCodeList(portal.PortalID); var storeSettings = new StoreSettings(portal.PortalID); foreach (var lang in culturecodeList) { var strContent = ""; // select all products var objCtrl = new NBrightBuyController(); var strFilter = " and NB1.ModifiedDate > convert(datetime,'" + lastrun.ToString("s") + "') "; if (debug) { strFilter = ""; } var l = objCtrl.GetList(portal.PortalID, -1, "PRD", strFilter); foreach (var p in l) { var prodData = new ProductData(p.ItemID, lang); strContent = prodData.Info.GetXmlProperty("genxml/textbox/txtproductref") + " : " + prodData.SEODescription + " " + prodData.SEOName + " " + prodData.SEOTagwords + " " + prodData.SEOTitle; if (strContent != "") { var tags = new List <String>(); tags.Add("nbsproduct"); //Get the description string string strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strContent, false), 100, "..."); var searchDoc = new SearchDocument(); // Assigns as a Search key the SearchItems' searchDoc.UniqueKey = prodData.Info.ItemID.ToString(""); searchDoc.QueryString = "ref=" + prodData.Info.GetXmlProperty("genxml/textbox/txtproductref"); searchDoc.Title = prodData.ProductName; searchDoc.Body = strContent; searchDoc.Description = strDescription; if (debug) { searchDoc.ModifiedTimeUtc = DateTime.Now.Date; } else { searchDoc.ModifiedTimeUtc = prodData.Info.ModifiedDate; } searchDoc.AuthorUserId = 1; searchDoc.TabId = storeSettings.ProductDetailTabId; searchDoc.PortalId = portal.PortalID; searchDoc.SearchTypeId = SearchHelper.Instance.GetSearchTypeByName("tab").SearchTypeId; searchDoc.CultureCode = lang; searchDoc.Tags = tags; //Add Module MetaData searchDoc.ModuleDefId = 0; searchDoc.ModuleId = 0; searchDocs.Add(searchDoc); } } } //Index InternalSearchController.Instance.AddSearchDocuments(searchDocs); InternalSearchController.Instance.Commit(); return(" - NBS-DNNIDX scheduler ACTIVATED "); }
private static void SearchArticleIndex(DataTable dt, SearchItemInfoCollection items, ModuleInfo modInfo) { for (int i = 0; i < dt.Rows.Count; i++) { DataRow row = dt.Rows[i]; var searchedContent = new StringBuilder(8192); //article name string name = HtmlUtils.Clean(row["Name"].ToString().Trim(), false); if (Utility.HasValue(name)) { searchedContent.AppendFormat("{0}{1}", name, " "); } else { //do we bother with the rest? continue; } //article text string articleText = row["ArticleText"].ToString().Trim(); if (Utility.HasValue(articleText)) { searchedContent.AppendFormat("{0}{1}", articleText, " "); } //article description string description = row["Description"].ToString().Trim(); if (Utility.HasValue(description)) { searchedContent.AppendFormat("{0}{1}", description, " "); } //article metakeyword string keyword = row["MetaKeywords"].ToString().Trim(); if (Utility.HasValue(keyword)) { searchedContent.AppendFormat("{0}{1}", keyword, " "); } //article metadescription string metaDescription = row["MetaDescription"].ToString().Trim(); if (Utility.HasValue(metaDescription)) { searchedContent.AppendFormat("{0}{1}", metaDescription, " "); } //article metatitle string metaTitle = row["MetaTitle"].ToString().Trim(); if (Utility.HasValue(metaTitle)) { searchedContent.AppendFormat("{0}{1}", metaTitle, " "); } string itemId = row["ItemId"].ToString(); var item = new SearchItemInfo { Title = name, Description = HtmlUtils.Clean(description, false), Author = Convert.ToInt32(row["AuthorUserId"], CultureInfo.InvariantCulture), PubDate = Convert.ToDateTime(row["LastUpdated"], CultureInfo.InvariantCulture), ModuleId = modInfo.ModuleID, SearchKey = "Article-" + itemId, Content = HtmlUtils.StripWhiteSpace( HtmlUtils.Clean(searchedContent.ToString(), false), true), GUID = "itemid=" + itemId }; items.Add(item); //Check if the Portal is setup to enable venexus indexing if (ModuleBase.AllowVenexusSearchForPortal(modInfo.PortalID)) { string indexUrl = Utility.GetItemLinkUrl(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), modInfo.PortalID, modInfo.TabID, modInfo.ModuleID); //UpdateVenexusBraindump(IDbTransaction trans, string indexTitle, string indexContent, string indexWashedContent) Data.DataProvider.Instance().UpdateVenexusBraindump(Convert.ToInt32(itemId, CultureInfo.InvariantCulture), name, articleText, HtmlUtils.Clean(articleText, false), modInfo.PortalID, indexUrl); } //} } }
/// <summary> /// Adds the given JToken to the specified Document. /// </summary> /// <param name="doc"> /// The Document to add to. /// </param> /// <param name="prefix"> /// The prefix to use for field names. /// </param> /// <param name="token"> /// The JToken to add. /// </param> /// <param name="fieldconfig"></param> private static void Add(Document doc, string prefix, JToken token, FieldConfig fieldconfig) { if (token is JObject) { AddProperties(doc, prefix, token as JObject, fieldconfig); } else if (token is JArray) { AddArray(doc, prefix, token as JArray, fieldconfig?.Items); } else if (token is JValue) { JValue value = token as JValue; bool index = false; bool sort = false; if (fieldconfig != null) { index = fieldconfig.Index; sort = fieldconfig.Sort; } switch (value.Type) //todo: simple date gets detected as string { case JTokenType.Boolean: if (index || sort) { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetIntValue((bool)value.Value ? 1 : 0)); } break; case JTokenType.Date: if (index || sort) { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetLongValue(((DateTime)value.Value).Ticks)); //doc.Add(new Field(prefix, DateTools.DateToString((DateTime)value.Value, DateTools.Resolution.SECOND), Field.Store.NO, Field.Index.NOT_ANALYZED)); /* * if (field != null ){ * if (field.IndexType == "datetime") * { * doc.Add(new Field(prefix, DateTools.DateToString((DateTime)value.Value, DateTools.Resolution.SECOND), Field.Store.NO, Field.Index.NOT_ANALYZED)); * } * else if (field.IndexType == "date") * { * doc.Add(new Field(prefix, DateTools.DateToString((DateTime)value.Value, DateTools.Resolution.DAY), Field.Store.NO, Field.Index.NOT_ANALYZED)); * } * else if (field.IndexType == "time") * { * doc.Add(new Field(prefix, DateTools.DateToString((DateTime)value.Value, DateTools.Resolution.SECOND).Substring(8), Field.Store.NO, Field.Index.NOT_ANALYZED)); * } * } * else * { * doc.Add(new Field(prefix, DateTools.DateToString((DateTime)value.Value, DateTools.Resolution.SECOND), Field.Store.NO, Field.Index.NOT_ANALYZED)); * } */ } break; case JTokenType.Float: if (index || sort) { if (value.Value is float) { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetFloatValue((float)value.Value)); } else { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetFloatValue((float)Convert.ToDouble(value.Value))); //doc.Add(new NumericField(prefix, Field.Store.NO, true).SetDoubleValue(Convert.ToDouble(value.Value))); } } break; case JTokenType.Guid: if (index || sort) { doc.Add(new Field(prefix, value.Value.ToString(), Field.Store.NO, Field.Index.NOT_ANALYZED)); } break; case JTokenType.Integer: if (index || sort) { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetFloatValue((float)Convert.ToInt64(value.Value))); //doc.Add(new NumericField(prefix, Field.Store.NO, true).SetLongValue(Convert.ToInt64(value.Value))); } break; case JTokenType.Null: break; case JTokenType.String: if (fieldconfig != null && fieldconfig.IndexType == "key") { doc.Add(new Field(prefix, QueryParser.Escape(value.Value.ToString()), Field.Store.NO, Field.Index.NOT_ANALYZED)); } else if (fieldconfig != null && fieldconfig.IndexType == "html") { if (index) { doc.Add(new Field(prefix, HtmlUtils.Clean(value.Value.ToString(), true), Field.Store.NO, Field.Index.ANALYZED)); } if (sort) { doc.Add(new Field("@" + prefix, HtmlUtils.Clean(Truncate(value.Value.ToString(), 100), true), Field.Store.NO, Field.Index.NOT_ANALYZED)); } } else { if (index) { doc.Add(new Field(prefix, value.Value.ToString(), Field.Store.NO, Field.Index.ANALYZED)); } if (sort) { doc.Add(new Field("@" + prefix, Truncate(value.Value.ToString(), 100), Field.Store.NO, Field.Index.NOT_ANALYZED)); } } break; case JTokenType.TimeSpan: if (index || sort) { doc.Add(new NumericField(prefix, Field.Store.NO, true).SetLongValue(((TimeSpan)value.Value).Ticks)); } break; case JTokenType.Uri: if (index || sort) { doc.Add(new Field(prefix, value.Value.ToString(), Field.Store.NO, Field.Index.ANALYZED)); } break; default: Debug.Fail("Unsupported JValue type: " + value.Type); break; } } else { Debug.Fail("Unsupported JToken: " + token); } }