Example #1
0
        /// <summary>
        /// Gets a URL linking to the given item when friendly URLs are turned on
        /// </summary>
        /// <param name="item">The item to link to.</param>
        /// <param name="tabId">The tab ID.</param>
        /// <param name="moduleId">The module ID.</param>
        /// <param name="pageId">The page ID.</param>
        /// <param name="portalSettings">The portal settings.</param>
        /// <param name="cultureName">The name of the current culture of the page, or <see cref="string.Empty"/></param>
        /// <param name="createFriendlyUrl">Whether to generate a friendly URL where the page name is the name of the item</param>
        /// <returns>A URL linking to the given item</returns>
        private static string GetItemLinkUrl(Item item, int tabId, int moduleId, int pageId, PortalSettings portalSettings, string cultureName, bool createFriendlyUrl)
        {
            TabInfo tabInfo;
            var     tabController       = new TabController();
            int?    queryStringModuleId = null;
            int     defaultTabId        = ModuleBase.DefaultDisplayTabIdForPortal(portalSettings.PortalId);

            // if the setting to "force display on this page" is set, be sure to send them there.
            if (!item.ForceDisplayOnPage() && tabId > 0 && item.DisplayOnCurrentPage())
            {
                if (!Utility.IsPageOverrideable(portalSettings.PortalId, tabId))
                {
                    // not overrideable, send them to default tab id
                    tabInfo = tabController.GetTab(defaultTabId, portalSettings.PortalId, false);
                }
                else
                {
                    tabInfo = tabController.GetTab(tabId, portalSettings.PortalId, false);

                    // check if there is a ModuleID passed in the querystring, if so then send it in the querystring as well
                    if (moduleId > 0)
                    {
                        queryStringModuleId = moduleId;
                    }
                }
            }
            else
            {
                tabInfo = tabController.GetTab(item.DisplayTabId, portalSettings.PortalId, false);
            }

            if (tabInfo == null || tabInfo.IsDeleted)
            {
                tabInfo = tabController.GetTab(defaultTabId, portalSettings.PortalId, false);
            }

            // if the tab doesn't have an overrideable module on it redirect them to the page without Publish querystring parameters, assuming it is force display on page
            if (item.ForceDisplayOnPage() && !Utility.IsPageOverrideable(portalSettings.PortalId, tabInfo.TabID))
            {
                return(Globals.NavigateURL(tabInfo.TabID));
            }

            return(NavigateURL(
                       tabInfo.TabID,
                       tabInfo.IsSuperTab,
                       portalSettings,
                       string.Empty,
                       cultureName,
                       createFriendlyUrl ? MakeUrlSafe(item.Name) + ".aspx" : null,
                       "itemId=" + item.ItemId.ToString(CultureInfo.InvariantCulture),
                       UsePageId(pageId, portalSettings.PortalId) ? "pageId=" + pageId.ToString(CultureInfo.InvariantCulture) : null,
                       queryStringModuleId.HasValue ? "moduleId=" + queryStringModuleId.Value.ToString(CultureInfo.InvariantCulture) : null));
        }
Example #2
0
 private void DisplayItem(Item item)
 {
     if (item != null && !item.IsLinkable() && Null.IsNull(ModuleBase.DefaultDisplayTabIdForPortal(item.PortalId)))
     {
         this.DisplayBrokenLinkMessage(item);
     }
     else
     {
         this.Response.Status           = "301 Moved Permanently";
         this.Response.RedirectLocation = item != null?UrlGenerator.GetItemLinkUrl(item, this.PortalSettings) : Globals.NavigateURL();
     }
 }
Example #3
0
        public static string GetItemLinkUrl(Item item, PortalSettings portalSettings, int tabId, int moduleId, int pageId, string cultureName)
        {
            string returnUrl = string.Empty;

            if (item != null)
            {
                if (!item.IsLinkable())
                {
                    tabId = ModuleBase.DefaultDisplayTabIdForPortal(portalSettings.PortalId);
                }

                returnUrl = GetItemLinkUrl(item, tabId, moduleId, pageId, portalSettings, cultureName, ModuleBase.EnablePublishFriendlyUrlsForPortal(item.PortalId));
            }

            return(returnUrl);
        }