/// <summary> /// Loads a single item into the html widget. /// </summary> public void LoadItem(Item item, Feed feed) { if (item == null || feed == null) return; page_number = 0; page_count = 0; this.feed = null; // render item into html string output = template.Replace ("@fuse_feed_name@", feed.Name); output = output.Replace ("@fuse_link@", item.Url); output = output.Replace ("@fuse_header@", item.Title); output = output.Replace ("@fuse_description@", item.Description); item.Read = true; parent.DataManager.UpdateItem (item); html.RenderData (output, feed.Url, "text/html"); feed.UpdateStatus (); }
// adds the new feed items void addNewItems(Feed feed, RssFeed rss_feed) { // only add in new items. backwards for (int i=rss_feed.Channel.Items.Count-1; i>=0; i--) { RssItem rss_item = rss_feed.Channel.Items [i]; bool exists = false; foreach (Item item in feed.Items) if (item.Title == rss_item.Title && item.Url == rss_item.Link && item.GUID == rss_item.Guid && item.PubDate == rss_item.PubDate) exists = true; // the list doesnt have the news item if (!exists) { Item new_item = new Item (rss_item); new_item.IsNew = true; // add in the new item Application.Invoke (delegate { feed.Items.Add (new_item); parent.DataManager.AddItem (feed, new_item); }); } } // update the feed Application.Invoke (delegate { feed.UpdateStatus (); parent.DataManager.UpdateFeed (feed); }); }
// loads the feed into the popup private void loadFeed(Feed feed) { page_number = 0; unread_items.Clear (); //find all the unread items foreach (Item item in feed.Items) if (item.IsNew) unread_items.Add (item); //create the links to be used in the popup links = new LinkButton[unread_items.Count]; for (int i=0; i<unread_items.Count; i++) { Item item = unread_items[i]; links[i] = new LinkButton (item.Url, item.Title); links[i].Xalign = 0; links[i].EnterNotifyEvent += button_enter; links[i].LeaveNotifyEvent += button_leave; //the link has been clicked links[i].Clicked += delegate (object o, EventArgs args) { parent.News.NewsViewer.LoadItem (item, feed); feed.UpdateStatus (); unread.Markup = feed.UnreadStatus; parent.News.NewsTree.QueueDraw (); }; } //get the amount of pages if (unread_items.Count > 0) { double item_count = (double) unread_items.Count; double show_count = (double) show_total+1; page_count = (int) Math.Ceiling (item_count / show_count); } else page_count = 0; //update the feed details title.Markup = Utils.ParseMarkup (feed.Name); unread.Markup = feed.UnreadStatus; refreshFeed (); //create the items generateItems (); }
// load the feed's items void loadItems(Feed feed) { string feed_id = getFeedID (feed); string sql = "SELECT title, description, url, guid, read, pub_date FROM item WHERE feed_id='" + feed_id + "'"; dbcon.Open (); IDbCommand dbcmd = dbcon.CreateCommand (); dbcmd.CommandText = sql; IDataReader reader = dbcmd.ExecuteReader (); while (reader.Read ()) { string title = reader.GetString (0); string description = reader.GetString (1); string url = reader.GetString (2); string guid = reader.GetString (3); bool read = reader.GetBoolean (4); string pub_date = reader.GetString (5); feed.Items.Add (new Item (title, description, url, guid, read, pub_date)); } reader.Close (); reader = null; dbcmd.Dispose (); dbcmd = null; dbcon.Close (); feed.UpdateStatus (); }