Beispiel #1
0
        /// <summary>
        ///   Adds a new url to the sitemap
        /// </summary>
        /// <param name = "sitemapUrl">The url to be included in the sitemap</param>
        /// <remarks>
        /// </remarks>
        private void AddURL(SitemapUrl sitemapUrl)
        {
            writer.WriteStartElement("url");
            writer.WriteElementString("loc", sitemapUrl.Url);
            writer.WriteElementString("lastmod", sitemapUrl.LastModified.ToString("yyyy-MM-dd"));
            writer.WriteElementString("changefreq", sitemapUrl.ChangeFrequency.ToString().ToLower());
            writer.WriteElementString("priority", sitemapUrl.Priority.ToString("F01", CultureInfo.InvariantCulture));

            OpenSitemapUrl openSitemapUrl = sitemapUrl as OpenSitemapUrl;

            if (openSitemapUrl != null)
            {
                foreach (var alt in openSitemapUrl.Alternates)
                {
                    writer.WriteStartElement("xhtml", "link", "http://www.w3.org/1999/xhtml");
                    writer.WriteAttributeString("rel", "alternate");
                    writer.WriteAttributeString("hreflang", alt.Hreflang);
                    writer.WriteAttributeString("href", alt.Href);
                    writer.WriteEndElement();
                }

                /*
                 * <xhtml:link
                 * rel="alternate"
                 * hreflang="de"
                 * href="http://www.exemple.com/deutsch/"
                 * />
                 */
            }


            writer.WriteEndElement();
        }
        /// <summary>
        ///   Return the sitemap url node for the page
        /// </summary>
        /// <param name = "objTab">The page being indexed</param>
        /// <param name="language">Culture code to use in the URL</param>
        /// <returns>A SitemapUrl object for the current page</returns>
        /// <remarks>
        /// </remarks>
        private OpenSitemapUrl GetPageUrl(TabInfo objTab, string language, params string[] AdditionalParameters)
        {
            var pageUrl = new OpenSitemapUrl();
            pageUrl.Url = Globals.NavigateURL(objTab.TabID, objTab.IsSuperTab, ps, "", language, AdditionalParameters);

            if (pageUrl.Url.ToLower().IndexOf(ps.PortalAlias.HTTPAlias.ToLower()) == -1)
            {
                // code to fix a bug in dnn5.1.2 for navigateurl
                if ((HttpContext.Current != null))
                {
                    pageUrl.Url = Globals.AddHTTP(HttpContext.Current.Request.Url.Host + pageUrl.Url);
                }
                else
                {
                    // try to use the portalalias
                    pageUrl.Url = Globals.AddHTTP(ps.PortalAlias.HTTPAlias.ToLower()) + pageUrl.Url;
                }
            }
            pageUrl.Priority = GetPriority(objTab);
            pageUrl.LastModified = objTab.LastModifiedOnDate;
            var modCtrl = new ModuleController();
            foreach (ModuleInfo m in modCtrl.GetTabModules(objTab.TabID).Values)
            {
                if (m.LastModifiedOnDate > objTab.LastModifiedOnDate)
                {
                    pageUrl.LastModified = m.LastModifiedOnDate;
                }
            }
            pageUrl.ChangeFrequency = SitemapChangeFrequency.Daily;

            return pageUrl;
        }