private DataSet FillPortalDS(int portalID, int userID, SqlDataReader portalSearchResult, out int hits)
        {
            hits = 0;
            DataSet ds = new DataSet();

            try
            {
                ds = CreatePortalDS(ds);

                string  strTmp, strLink, strModuleName;
                string  strModuleID, strItemID, strLocate;
                string  strTabID, strTabName;
                string  strModuleGuidID, strModuleTitle;
                DataRow dr;

                try
                {
                    while (hits <= maxHits && portalSearchResult.Read())
                    {
                        dr = ds.Tables["PortalSearch"].NewRow();

                        strModuleName   = portalSearchResult.GetString(0);
                        strModuleID     = portalSearchResult.GetInt32(3).ToString();
                        strItemID       = portalSearchResult.GetInt32(4).ToString();
                        strLocate       = "mID=" + strModuleID + "&ItemID=" + strItemID;
                        strTabID        = portalSearchResult.GetInt32(7).ToString();
                        strTabName      = portalSearchResult.GetString(8).ToString();
                        strModuleGuidID = portalSearchResult.GetGuid(9).ToString().ToUpper();
                        strModuleTitle  = portalSearchResult.GetString(10);
                        //strLink = Rainbow.Settings.Path.ApplicationRoot;

                        // [email protected]
                        // Changed the way links were created so that it utilises BuildUrl.
                        switch (strModuleGuidID)
                        {
                        case "2D86166C-4BDC-4A6F-A028-D17C2BB177C8":                                   //Discussions
                            // Mark McFarlane
                            // added support for a new page that lets you view an entire thread
                            // URL requires tabID = 0
                            strLink = HttpUrlBuilder.BuildUrl("~/DesktopModules/Discussion/DiscussionViewThread.aspx", 0, strLocate);
                            break;

                        case "2502DB18-B580-4F90-8CB4-C15E6E531012":                                   //Tasks
                            strLink = HttpUrlBuilder.BuildUrl("~/DesktopModules/Tasks/TasksView.aspx", Convert.ToInt32(strTabID), strLocate);
                            break;

                        case "87303CF7-76D0-49B1-A7E7-A5C8E26415BA":                                  //Articles
                            // Rob Siera
                            // Added support to link to the article itself, instead op the page of with article module
                            strLink = HttpUrlBuilder.BuildUrl("~/DesktopModules/Articles/ArticlesView.aspx", 0, strLocate);
                            break;

                        case "EC24FABD-FB16-4978-8C81-1ADD39792377":                                  //Products
                            // Manu
                            int tabID = PortalSettings.GetRootTab(Convert.ToInt32(strTabID), portalSettings.DesktopTabs).TabID;
                            strLink = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", tabID, "mID=" + strModuleID + "&ItemID=" + strTabID);
                            break;

                        case "875254B7-2471-491F-BAF8-4AFC261CC224":                                  //EnhancedHtml
                            // José Viladiu
                            // Added support to link to the specific page
                            strLink = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", Convert.ToInt32(strTabID), strLocate);
                            break;

                        default:
                            strLink = HttpUrlBuilder.BuildUrl(Convert.ToInt32(strTabID));                                      // "/DesktopDefault.aspx?tabID=" + ;
                            break;
                        }


                        //if (showImage)
                        //{
                        //	dr["Image"] = "<a href='" + strLink + "'>" + strModuleGuidID + ".gif" + "</a>";
                        //}

                        if (showModuleName)
                        {
                            dr["Module"] = strModuleName;
                        }

                        if (showModuleTitle)
                        {
                            dr["Module Title"] = strModuleTitle;
                        }

                        if (showTitle)
                        {
                            if (strModuleGuidID == "0B113F51-FEA3-499A-98E7-7B83C192FDBB" ||                              //Html Document
                                strModuleGuidID == "2B113F51-FEA3-499A-98E7-7B83C192FDBB")                                //Html WYSIWYG Edit (V2)
                            {
                                // We use the database field [rb.Modules].[ModuleTitle]:
                                strTmp = strModuleTitle;
                            }
                            else
                            {
                                if (portalSearchResult.IsDBNull(1))
                                {
                                    strTmp = Esperantus.Localize.GetString("PORTALSEARCH_MISSING", "Missing", null);
                                }
                                else
                                {
                                    strTmp = portalSearchResult.GetString(1);
                                }
                            }
                            dr["Title"]      = "<a href='" + strLink + "'>" + strTmp + "</a>";
                            dr["cleanTitle"] = strTmp;
                        }

                        if (showAbstract)
                        {
                            if (portalSearchResult.IsDBNull(2))
                            {
                                strTmp = Esperantus.Localize.GetString("PORTALSEARCH_MISSING", "Missing", null);
                            }
                            else
                            {
                                strTmp = portalSearchResult.GetString(2);
                            }

                            // Remove any html tags:
                            HTMLText html = SearchHelper.DeleteBeforeBody(Server.HtmlDecode(strTmp));
                            dr["Abstract"] = html.InnerText;
                        }

                        if (showCreatedByUser)
                        {
                            if (portalSearchResult.IsDBNull(5))
                            {
                                strTmp = Esperantus.Localize.GetString("PORTALSEARCH_MISSING", "Missing", null);
                            }
                            else
                            {
                                strTmp = portalSearchResult.GetString(5);
                            }
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (strTmp == "unknown")
                            {
                                strTmp = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                            dr["User"] = strTmp;
                        }

                        if (showCreatedDate)
                        {
                            if (portalSearchResult.IsDBNull(6))
                            {
                                strTmp = Esperantus.Localize.GetString("PORTALSEARCH_MISSING", "Missing", null);
                            }
                            else
                            {
                                try
                                {
                                    strTmp = portalSearchResult.GetDateTime(6).ToShortDateString();
                                }
                                catch
                                {
                                    strTmp = string.Empty;
                                }
                            }

                            // If GetDateTime(6) is an empty string the date "1/1/1900" is returned.
                            if (strTmp == "1/1/1900")
                            {
                                strTmp = string.Empty;
                            }
                            dr["Date"] = strTmp;
                        }

                        if (showLink)
                        {
                            dr["Link"] = "<a href='" + strLink + "'>" + strLink + "</a>";
                        }

                        if (showTabName)
                        {
                            if (portalSearchResult.IsDBNull(8))
                            {
                                strTmp = Esperantus.Localize.GetString("PORTALSEARCH_MISSING", "Missing", null);
                            }
                            else
                            {
                                strTmp = portalSearchResult.GetString(8);
                            }
                            dr["Tab"] = "<a href='" + HttpUrlBuilder.BuildUrl(Convert.ToInt32(strTabID)) + "'>" + strTmp + "</a>";
                        }

                        if (showTestInfo)
                        {
                            dr["TestInfo"] = "ModuleGuidID=" + strModuleGuidID + "<br>" +
                                             "ModuleID=" + strModuleID + ", ItemID=" + strItemID + "<br>" +
                                             "PortalID=" + portalID.ToString() + ", UserID=" + userID.ToString() + "<br>" +
                                             "TabID=" + strTabID + ", TabName=" + strTabName;
                        }

                        ds.Tables["PortalSearch"].Rows.Add(dr);
                        hits++;
                    }
                }
                finally
                {
                    portalSearchResult.Close();
                }
            }
            catch (Exception e)
            {
                lblHits.Text = e.Message;
                return(null);
            }
            return(ds);
        }