Exemplo n.º 1
0
        private string GetExtraFieldValue(int articleId, int articleModuleId, string tagname)
        {
            //Determine ID of ExtraField
            var extraFieldId = -1;

            if (!_extrafieldIds.ContainsKey(tagname + articleModuleId))
            {
                var lst = new ExtraFieldController().GetByModules(articleModuleId);
                foreach (ExtraFieldInfo o in lst.Where(o => o.Tag == tagname))
                {
                    extraFieldId = o.ItemID;
                    break;
                }
                _extrafieldIds.Add(tagname + articleModuleId, extraFieldId);
            }

            extraFieldId = _extrafieldIds[tagname + articleModuleId];
            if (extraFieldId != -1)
            {
                //Retrieve ExtraField value
                var oFieldValue = new FieldValueController().GetFieldValue(extraFieldId, articleId);
                if (oFieldValue != null)
                {
                    return(oFieldValue.FieldValue);
                }
            }

            return("");
        }
        private SitemapUrl  GetBlogUrl(DNNArticleInfo article)
        {
            if (!_modulePriority.ContainsKey(article.ModuleId))
            {
                var settings = new ModuleController().GetModuleSettings(article.ModuleId);
                if (!string.IsNullOrEmpty(Convert.ToString(settings[MySettings.SiteMapPriority])))
                {
                    try
                    {
                        _modulePriority.Add(article.ModuleId, Convert.ToSingle(settings[MySettings.SiteMapPriority]));
                    }
                    catch (Exception)
                    {
                        _modulePriority.Add(article.ModuleId, 0.5f);
                    }
                }
                else
                {
                    _modulePriority.Add(article.ModuleId, 0.5f);
                }

                if (!string.IsNullOrEmpty(Convert.ToString(settings[MySettings.SiteMapPriorityFieldId])))
                {
                    _modulePriorityFieldId.Add(article.ModuleId, Convert.ToInt32(settings[MySettings.SiteMapPriorityFieldId]));
                }
                else
                {
                    _modulePriorityFieldId.Add(article.ModuleId, -1);
                }
            }

            float priority = _modulePriority[article.ModuleId];
            int   fieldid  = _modulePriorityFieldId[article.ModuleId];

            if (!Null.IsNull(fieldid))
            {
                var o = new FieldValueController().GetFieldValue(fieldid, article.ItemId);
                if (o != null)
                {
                    var prio = o.GetValue();
                    if (!string.IsNullOrEmpty(prio))
                    {
                        priority = Convert.ToSingle(prio);
                    }
                }
            }
            var pageUrl = new SitemapUrl
            {
                Url =
                    Modules.DNNArticle.TokenProcessor.GetViewURL(article, Null.NullInteger,
                                                                 Null.NullInteger),
                Priority        = priority,
                LastModified    = article.PublishDate,
                ChangeFrequency = SitemapChangeFrequency.Weekly
            };

            return(pageUrl);
        }