public static List<Guid> guidanceItems_SearchTitleAndHtml(this TM_Xml_Database tmDatabase, List<Guid> guidanceItemsIds, string searchText)
{
List<TeamMentor_Article> guidanceItems;
var searchTitleAndBody = true;
//first see if there are special tags in the seach text
if (searchText.starts("all:")) // means we want to do a full search
{
guidanceItemsIds.Clear();
searchText = searchText.remove("all:");
}
else if (searchText.starts("title:"))
{
searchTitleAndBody = false;
searchText = searchText.remove("title:");
}
//figure out which guidanceItems to search on
switch (guidanceItemsIds.size())
{
case 0: // if there are no guidanceItemsIds provided, search on all of them
guidanceItems = tmDatabase.xmlDB_GuidanceItems() ;
break;
case 1: // handle special case where the ID provided is from a library, folder or view
var id = guidanceItemsIds.first();
guidanceItems =tmDatabase.getGuidanceItems_from_LibraryFolderOrView(id);
if (guidanceItems.isNull()) // if there was no mapping, use the id as a GuidanceItem ID
guidanceItems = tmDatabase.xmlDB_GuidanceItems(guidanceItemsIds);
break;
default:
guidanceItems = tmDatabase.xmlDB_GuidanceItems(guidanceItemsIds);
break;
}
if (searchTitleAndBody)
return tmDatabase.guidanceItems_SearchTitleAndHtml(guidanceItems, searchText);
return tmDatabase.guidanceItems_SearchTitle(guidanceItems, searchText);
}