//MH: end #endregion /// <summary> /// Do databind. /// Thanks to abain for cleaning up the code /// </summary> public override void DataBind() { bool currentTabOnly = (Bind == BindOption.BindOptionCurrentChilds); // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; // Build list of tabs to be shown to user ArrayList authorizedTabs = new ArrayList(); int addedTabs = 0; for (int i = 0; i < portalSettings.DesktopPages.Count; i++) { PageStripDetails tab = (PageStripDetails)portalSettings.DesktopPages[i]; if (PortalSecurity.IsInRoles(tab.AuthorizedRoles)) { authorizedTabs.Add(tab); } addedTabs++; } //Menu // add the shop home! AddShopHomeNode(); if (!currentTabOnly) { for (int i = 0; i < authorizedTabs.Count; i++) { PageStripDetails myTab = (PageStripDetails)authorizedTabs[i]; AddMenuTreeNode(i, myTab); } } else { if (authorizedTabs.Count >= 0) { PageStripDetails myTab = PortalSettings.GetRootPage(portalSettings.ActivePage, authorizedTabs); if (myTab.Pages.Count > 0) { for (int i = 0; i < myTab.Pages.Count; i++) { PageStripDetails mySubTab = (PageStripDetails)myTab.Pages[i]; AddMenuTreeNode(0, mySubTab); } } } } base.DataBind(); }
/// <summary> /// Populates ArrayList of tabs based on binding option selected. /// </summary> /// <returns></returns> protected object GetInnerDataSource() { ArrayList authorizedTabs = new ArrayList(); if (HttpContext.Current != null) { // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; switch (Bind) { case BindOption.BindOptionTop: { authorizedTabs = GetTabs(0, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); break; } case BindOption.BindOptionCurrentChilds: { int currentTabRoot = PortalSettings.GetRootPage(portalSettings.ActivePage, portalSettings.DesktopPages). PageID; authorizedTabs = GetTabs(currentTabRoot, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); break; } case BindOption.BindOptionSubtabSibling: { int currentTabRoot; if (portalSettings.ActivePage.ParentPageID == 0) { currentTabRoot = portalSettings.ActivePage.PageID; } else { currentTabRoot = portalSettings.ActivePage.ParentPageID; } authorizedTabs = GetTabs(currentTabRoot, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); break; // int tmpPageID = 0; // // if(portalSettings.ActivePage.ParentPageID == 0) // { // tmpPageID = portalSettings.ActivePage.PageID; // } // else // { // tmpPageID = portalSettings.ActivePage.ParentPageID; // } // ArrayList parentTabs = GetTabs(tmpPageID, portalSettings.DesktopPages); // try // { // if (parentTabs.Count > 0) // { // PageStripDetails currentParentTab = (PageStripDetails) parentTabs[this.SelectedIndex]; // this.SelectedIndex = -1; // authorizedTabs = GetTabs(portalSettings.ActivePage.PageID, currentParentTab.Pages); // } // } // catch // {} // break; } case BindOption.BindOptionChildren: { authorizedTabs = GetTabs(portalSettings.ActivePage.PageID, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); break; } case BindOption.BindOptionSiblings: { authorizedTabs = GetTabs(portalSettings.ActivePage.ParentPageID, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); break; } //MH: added 19/09/2003 by [email protected] case BindOption.BindOptionTabSibling: { authorizedTabs = GetTabs(portalSettings.ActivePage.PageID, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); if (authorizedTabs.Count == 0) { authorizedTabs = GetTabs(portalSettings.ActivePage.ParentPageID, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); } break; } //MH: added 29/04/2003 by [email protected] case BindOption.BindOptionDefinedParent: if (ParentPageID != -1) { authorizedTabs = GetTabs(ParentPageID, portalSettings.ActivePage.PageID, portalSettings.DesktopPages); } break; //MH: end default: { break; } } } return(authorizedTabs); }
/// <summary> /// Fills the portal DS. /// </summary> /// <param name="portalID">The portal ID.</param> /// <param name="userID">The user ID.</param> /// <param name="portalSearchResult">The portal search result.</param> /// <param name="hits">The hits.</param> /// <returns></returns> private DataSet FillPortalDS(int portalID, Guid 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.Framework.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/CommunityModules/Discussion/DiscussionViewThread.aspx", 0, strLocate); break; case "2502DB18-B580-4F90-8CB4-C15E6E531012": //Tasks strLink = HttpUrlBuilder.BuildUrl("~/DesktopModules/CommunityModules/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/CommunityModules/Articles/ArticlesView.aspx", 0, strLocate); break; case "EC24FABD-FB16-4978-8C81-1ADD39792377": //Products // Manu int tabID = PortalSettings.GetRootPage(Convert.ToInt32(strTabID), portalSettings.DesktopPages). PageID; 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 = General.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 = General.GetString("PORTALSEARCH_MISSING", "Missing", null); } else { strTmp = portalSearchResult.GetString(2); } // Remove any html tags: //HTMLText html = SearchHelper.DeleteBeforeBody(Server.HtmlDecode(strTmp)); // security script: Regex.Replace(strTmp, @"</?(?i:script|color|font|align|strong|font|div|class|modulepadding|modulescrollbars|body|embed|object|frameset|frame|iframe|meta|link|style)(.|\n)*?>", string.Empty); dr["Abstract"] = Regex.Replace(Server.HtmlDecode(strTmp), @"<(.|\n)*?>", string.Empty); } if (showCreatedByUser) { if (portalSearchResult.IsDBNull(5)) { strTmp = General.GetString("PORTALSEARCH_MISSING", "Missing", null); } else { strTmp = portalSearchResult.GetString(5); } // 15/7/2004 added localization by Mario Endara [email protected] if (strTmp == "unknown") { strTmp = General.GetString("UNKNOWN", "unknown"); } dr["User"] = strTmp; } if (showCreatedDate) { if (portalSearchResult.IsDBNull(6)) { strTmp = General.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 = General.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) { lblError.Text = "We are sorry, an error occurred processing your request."; lblError.Visible = true; ErrorHandler.Publish(LogLevel.Error, e); return(null); } return(ds); }