Menu

[r1]: / trunk / Source / Modules / Blog / BlogModule.cs  Maximize  Restore  History

Download this file

127 lines (100 with data), 4.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#region Copyright © 2004, Nicholas Berardi
/*
* ManagedFusion (www.ManagedFusion.net) Copyright © 2004, Nicholas Berardi
* All rights reserved.
*
* This code is protected under the Common Public License Version 1.0
* The license in its entirety at <http://opensource.org/licenses/cpl.php>
*
* ManagedFusion is freely available from <http://www.ManagedFusion.net/>
*/
#endregion
using System;
using System.Data;
using System.Text.RegularExpressions;
// ManagedFusion Classes
using ManagedFusion;
using ManagedFusion.Modules;
using ManagedFusion.Data;
// OmniPortal Classes
using OmniPortal.Modules.Blog.Data;
// Atom Classes
using Atom.Core;
namespace OmniPortal.Modules.Blog
{
[Module("Blog Module",
"This module is a web-log (blog), which is used to post a log about what you find informing.",
"{A7181415-44BC-48aa-9519-2AFC69DCB92A}",
"Blog",
TraversablePath = true)]
public class BlogModule : ModuleBase
{
#region OnLoadSyndication
protected override void OnLoadSyndication(LoadSyndicationEventArgs e)
{
BlogDatabaseProvider dbprovider = Databases.Providers["OmniPortalBlog"] as BlogDatabaseProvider;
BlogItem[] blogs = dbprovider.GetBlogs(this.Context);
DateTime modified = DateTime.MinValue;
// set the title for the feed
e.Feed.Title = new AtomContentConstruct("title", this.Properties["BlogTitle"]);
// populate content for syndication
foreach(BlogItem blog in blogs)
{
// check to see if this blog is suppose to be syndicated
// or has even been published yet
if (blog.Syndicate == false || blog.Published == false)
continue;
// check to see if the blog date modified is more recent than
// the previous modified value
if (blog.Modified > modified)
modified = blog.Modified;
// get url id for the current entry
Uri permalink = Common.Path.GetPortalUrl(String.Format("/archive/{0}.aspx", blog.ID));
// add the item
AtomEntry entry = new AtomEntry();
// set the author
entry.Author = new AtomPersonConstruct("author", "Fix Me"); // new AtomPersonConstruct("author", blog.Poster.FullName);
// set the title
entry.Title = new AtomContentConstruct("title", blog.Title);
// if there is a url for the title
if (blog.TitleUrl != null)
try { entry.Links.Add(new AtomLink(blog.TitleUrl, Relationship.Alternate, MediaType.TextHtml, blog.Title)); }
catch { }
// if there is a source url
if (blog.SourceUrl != null)
try { entry.Links.Add(new AtomLink(blog.SourceUrl, Relationship.Alternate, MediaType.TextHtml, blog.Source)); }
catch { }
// set the permalink
entry.Id = permalink;
// set the date time stamps for this entry
entry.Created = new AtomDateConstruct("created", blog.Created);
entry.Issued = new AtomDateConstruct("issued", blog.Issued);
entry.Modified = new AtomDateConstruct("modified", blog.Modified);
// set the body contents
entry.Contents.Add(new AtomContent(blog.Body, MediaType.TextHtml, Mode.Escaped));
// add entry to the feed
e.Feed.Entries.Add(entry);
}
// set the time the feed was last modified
e.Feed.Modified = new AtomDateConstruct("modified", modified);
base.OnLoadSyndication (e);
}
#endregion
protected override void OnLoad(LoadModuleEventArgs e)
{
// add the blog style sheet to the page.
Common.PageBuilder.StyleSheets.Add(this.GetUrlPath("blog.css").ToString());
// check to see if the current has a role with the task of Poster
if (this.IsInTask("Poster"))
{
// add admin links section to the portlets.
e.GetHolder(0).Add(this.CreatePortlet(1, "Admin Links", this.GetControl("Portlets/Admin.ascx")));
}
// add public links section to the protlets
e.GetHolder(0).Add(this.CreatePortlet(2, (this.IsInTask("Poster") ? "Public " : String.Empty) + "Links", this.GetControl("Portlets/Public.ascx")));
// add calendar to the portlets
e.GetHolder(0).Add(this.CreatePortlet(3, "Archive Calendar", this.GetControl("Portlets/Calendar.ascx")));
base.OnLoad (e);
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.