Exemplo n.º 1
0
        public bool DisplayReturnToList()
        {
            ItemVersionSetting rlSetting = ItemVersionSetting.GetItemVersionSetting(ItemVersionId, "ArticleSettings", "DisplayReturnToList", PortalId);

            if (rlSetting != null)
            {
                return(Convert.ToBoolean(rlSetting.PropertyValue, CultureInfo.InvariantCulture));
            }
            return(false);
        }
Exemplo n.º 2
0
        private void Page_Load(object sender, EventArgs e)
        {
            //PortalSettings ps = (PortalSettings)HttpContext.Current.Items["PortalSettings"];
            PortalSettings ps = Utility.GetPortalSettings(PortalId);

            Response.ContentType     = "text/xml";
            Response.ContentEncoding = Encoding.UTF8;

            var sw = new StringWriter(CultureInfo.InvariantCulture);
            var wr = new XmlTextWriter(sw);

            wr.WriteStartElement("rss");
            wr.WriteAttributeString("version", "2.0");
            wr.WriteAttributeString("xmlns:wfw", "http://wellformedweb.org/CommentAPI/");
            wr.WriteAttributeString("xmlns:slash", "http://purl.org/rss/1.0/modules/slash/");
            wr.WriteAttributeString("xmlns:dc", "http://purl.org/dc/elements/1.1/");
            wr.WriteAttributeString("xmlns:trackback", "http://madskills.com/public/xml/rss/module/trackback/");

            wr.WriteStartElement("channel");
            wr.WriteElementString("title", ps.PortalName);
            if (ps.PortalAlias.HTTPAlias.IndexOf("http://", StringComparison.OrdinalIgnoreCase) == -1)
            {
                wr.WriteElementString("link", "http://" + ps.PortalAlias.HTTPAlias);
            }
            else
            {
                wr.WriteElementString("link", ps.PortalAlias.HTTPAlias);
            }
            wr.WriteElementString("description", "RSS Feed for " + ps.PortalName);
            wr.WriteElementString("ttl", "120");

            //TODO: look into options for how to display the "Title" of the RSS feed
            var dt = new DataTable {
                Locale = CultureInfo.InvariantCulture
            };

            if (DisplayType == "ItemListing" || DisplayType == null)
            {
                dt = ItemId == -1 ? DataProvider.Instance().GetMostRecent(ItemTypeId, NumberOfItems, PortalId) : DataProvider.Instance().GetMostRecentByCategoryId(ItemId, ItemTypeId, NumberOfItems, PortalId);
            }
            else if (DisplayType == "CategoryFeature")
            {
                DataSet ds = DataProvider.Instance().GetParentItems(ItemId, PortalId, RelationshipTypeId);
                dt = ds.Tables[0];
            }
            else if (DisplayType == "TagFeed")
            {
                if (AllowTags && _tagQuery != null && _tagQuery.Count > 0)
                {
                    string tagCacheKey = Utility.CacheKeyPublishTag + PortalId + ItemTypeId.ToString(CultureInfo.InvariantCulture) + _qsTags;
                    // +"PageId";
                    dt = DataCache.GetCache(tagCacheKey) as DataTable;
                    if (dt == null)
                    {
                        //ToDo: we need to make getitemsfromtags use the numberofitems value
                        dt = Tag.GetItemsFromTags(PortalId, _tagQuery);
                        //TODO: we should sort the tags
                        //TODO: should we set a 5 minute cache on RSS?
                        DataCache.SetCache(tagCacheKey, dt, DateTime.Now.AddMinutes(5));
                        Utility.AddCacheKey(tagCacheKey, PortalId);
                    }
                }
            }
            if (dt != null)
            {
                DataView dv = dt.DefaultView;
                if (dv.Table.Columns.IndexOf("dateColumn") > 0)
                {
                    dv.Table.Columns.Add("dateColumn", typeof(DateTime));
                    foreach (DataRowView dr in dv)
                    {
                        dr["dateColumn"] = Convert.ToDateTime(dr["startdate"]);
                    }

                    dv.Sort = " dateColumn desc ";
                }

                for (int i = 0; i < dv.Count; i++)
                {
                    //DataRow r = dt.Rows[i];
                    DataRow r = dv[i].Row;
                    wr.WriteStartElement("item");

                    //				wr.WriteElementString("slash:comments", objArticle.CommentCount.ToString());
                    //                wr.WriteElementString("wfw:commentRss", "http://" & Request.Url.Host & Me.ResolveUrl("RssComments.aspx?TabID=" & m_tabID & "&ModuleID=" & m_moduleID & "&ArticleID=" & objArticle.ArticleID.ToString()).Replace(" ", "%20"));
                    //                wr.WriteElementString("trackback:ping", "http://" & Request.Url.Host & Me.ResolveUrl("Tracking/Trackback.aspx?ArticleID=" & objArticle.ArticleID.ToString() & "&PortalID=" & _portalSettings.PortalId.ToString() & "&TabID=" & _portalSettings.ActiveTab.TabID.ToString()).Replace(" ", "%20"));

                    string title       = String.Empty,
                           description = String.Empty,
                           childItemId = String.Empty,
                           thumbnail   = String.Empty,
                           guid        = String.Empty,
                           author      = string.Empty;

                    DateTime startDate = DateTime.MinValue;

                    if (DisplayType == null || string.Equals(DisplayType, "ItemListing", StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(DisplayType, "TagFeed", StringComparison.OrdinalIgnoreCase))
                    {
                        title       = r["ChildName"].ToString();
                        description = r["ChildDescription"].ToString();
                        childItemId = r["ChilditemId"].ToString();
                        guid        = r["itemVersionIdentifier"].ToString();
                        startDate   = (DateTime)r["StartDate"];
                        thumbnail   = r["Thumbnail"].ToString();
                        author      = r["Author"].ToString();

                        //UserController uc = new UserController();
                        //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString()));
                        //if(ui!=null)
                        //author = ui.DisplayName;
                    }
                    else if (string.Equals(DisplayType, "CategoryFeature", StringComparison.OrdinalIgnoreCase))
                    {
                        title       = r["Name"].ToString();
                        description = r["Description"].ToString();
                        childItemId = r["itemId"].ToString();
                        guid        = r["itemVersionIdentifier"].ToString();
                        startDate   = (DateTime)r["StartDate"];
                        thumbnail   = r["Thumbnail"].ToString();
                        author      = r["Author"].ToString();

                        //UserController uc = new UserController();
                        //UserInfo ui = uc.GetUser(PortalId, Convert.ToInt32(r["AuthorUserId"].ToString()));
                        //if (ui != null)
                        //author = ui.DisplayName;
                    }

                    if (!Uri.IsWellFormedUriString(thumbnail, UriKind.Absolute) && thumbnail != string.Empty)
                    {
                        var thumnailLink = new Uri(Request.Url, ps.HomeDirectory + thumbnail);
                        thumbnail = thumnailLink.ToString();
                    }

                    wr.WriteElementString("title", title);

                    //if the item isn't disabled add the link
                    if (!Utility.IsDisabled(Convert.ToInt32(childItemId, CultureInfo.InvariantCulture), PortalId))
                    {
                        wr.WriteElementString("link", Utility.GetItemLinkUrl(childItemId, PortalId));
                    }

                    //wr.WriteElementString("description", Utility.StripTags(this.Server.HtmlDecode(description)));
                    description = Utility.ReplaceTokens(description);
                    wr.WriteElementString("description", Server.HtmlDecode(description));
                    //wr.WriteElementString("author", Utility.StripTags(this.Server.HtmlDecode(author)));
                    wr.WriteElementString("thumbnail", thumbnail);

                    wr.WriteElementString("dc:creator", author);

                    wr.WriteElementString("pubDate", startDate.ToUniversalTime().ToString("r", CultureInfo.InvariantCulture));

                    //file attachment enclosure
                    ItemVersionSetting attachmentSetting = ItemVersionSetting.GetItemVersionSetting(Convert.ToInt32(r["ItemVersionId"].ToString()), "ArticleSettings", "ArticleAttachment", PortalId);
                    if (attachmentSetting != null)
                    {
                        if (attachmentSetting.PropertyValue.Length > 7)
                        {
                            //var fileController = new FileController();
                            var fileManager = new FileManager();
                            int fileId      = Convert.ToInt32(attachmentSetting.PropertyValue.Substring(7));

                            var    fi      = fileManager.GetFile(fileId); //fileController.GetFileById(fileId, PortalId);
                            string fileurl = "http://" + PortalSettings.PortalAlias.HTTPAlias + PortalSettings.HomeDirectory + fi.Folder + fi.FileName;
                            wr.WriteStartElement("enclosure");
                            wr.WriteAttributeString("url", fileurl);
                            wr.WriteAttributeString("length", fi.Size.ToString());
                            wr.WriteAttributeString("type", fi.ContentType);
                            wr.WriteEndElement();
                        }
                    }

                    wr.WriteStartElement("guid");

                    wr.WriteAttributeString("isPermaLink", "false");

                    wr.WriteString(guid);
                    //wr.WriteString(itemVersionId);


                    wr.WriteEndElement();

                    wr.WriteEndElement();
                }
            }

            wr.WriteEndElement();
            wr.WriteEndElement();
            Response.Write(sw.ToString());
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method will configure the default ItemVersionSettings for an article, it is called from the Create method on article so that users of the API do not have to pass in itemversionsettings.
        /// </summary>
        private void SetDefaultItemVersionSettings()
        {
            //Printer Friendly
            string  hostPrinterFriendlySetting = HostController.Instance.GetString(Utility.PublishDefaultPrinterFriendly + PortalId.ToString(CultureInfo.InvariantCulture));
            Setting setting = Setting.PrinterFriendly;

            setting.PropertyValue = Convert.ToBoolean(hostPrinterFriendlySetting, CultureInfo.InvariantCulture).ToString();
            var itemVersionSetting = new ItemVersionSetting(setting);

            VersionSettings.Add(itemVersionSetting);

            //Email A Friend
            string hostEmailFriendSetting = HostController.Instance.GetString(Utility.PublishDefaultEmailAFriend + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.EmailAFriend;
            setting.PropertyValue = Convert.ToBoolean(hostEmailFriendSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //ratings
            string hostRatingSetting = HostController.Instance.GetString(Utility.PublishDefaultRatings + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Rating;
            setting.PropertyValue = Convert.ToBoolean(hostRatingSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //comments
            string hostCommentSetting = HostController.Instance.GetString(Utility.PublishDefaultComments + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Comments;
            setting.PropertyValue = Convert.ToBoolean(hostCommentSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            if (ModuleBase.IsPublishCommentTypeForPortal(PortalId))
            {
                //forum comments
                setting = Setting.ForumComments;
                setting.PropertyValue = Convert.ToBoolean(hostCommentSetting, CultureInfo.InvariantCulture).ToString();
                itemVersionSetting    = new ItemVersionSetting(setting);
                VersionSettings.Add(itemVersionSetting);
            }

            //include all articles from the parent category
            setting = Setting.ArticleSettingIncludeCategories;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //display on current page option
            setting = Setting.ArticleSettingCurrentDisplay;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //force display on specific page
            setting = Setting.ArticleSettingForceDisplay;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //display return to list
            setting = Setting.ArticleSettingReturnToList;
            setting.PropertyValue = false.ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //show author
            string hostAuthorSetting = HostController.Instance.GetString(Utility.PublishDefaultShowAuthor + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.Author;
            setting.PropertyValue = Convert.ToBoolean(hostAuthorSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);

            //show tags
            string hostTagsSetting = HostController.Instance.GetString(Utility.PublishDefaultShowTags + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.ShowTags;
            setting.PropertyValue = Convert.ToBoolean(hostTagsSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);


            //use approvals
            string hostUseApprovalsSetting = HostController.Instance.GetString(Utility.PublishUseApprovals + PortalId.ToString(CultureInfo.InvariantCulture));

            setting = Setting.UseApprovals;
            setting.PropertyValue = Convert.ToBoolean(hostUseApprovalsSetting, CultureInfo.InvariantCulture).ToString();
            itemVersionSetting    = new ItemVersionSetting(setting);
            VersionSettings.Add(itemVersionSetting);
        }