Ejemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Added EsperantusKeys for Localization
            // Mario Endara [email protected] june-1-2004
            Feedback = Esperantus.Localize.GetString("BLOG_FEEDBACK");

            if (!IsPostBack)
            {
                lnkRSS.HRef       = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Blog/RSS.aspx", TabID, "&mID=" + ModuleID);
                imgRSS.Src        = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Blog/xml.gif");
                lblCopyright.Text = moduleSettings["Copyright"].ToString();

                BlogDB blogDB = new BlogDB();
                int    month  = -1;
                int    year   = -1;
                try
                {
                    month = int.Parse(Request.Params.Get("month"));
                    year  = int.Parse(Request.Params.Get("year"));
                }
                catch {}

                if ((month > -1) && (year > -1))
                {
                    this.lblHeader.Text = Esperantus.Localize.GetString("BLOG_POSTSFROM", "Posts From", null) +
                                          " " + DateTime.Parse(month.ToString() + "/1/" + year.ToString()).ToString("MMMM, yyyy");
                    myDataList.DataSource = blogDB.GetBlogEntriesByMonth(month, year, ModuleID);
                }
                else
                {
                    myDataList.DataSource = blogDB.GetBlogs(ModuleID);
                }
                myDataList.DataBind();

                dlArchive.DataSource = blogDB.GetBlogMonthArchive(ModuleID);
                dlArchive.DataBind();

                SqlDataReader dataReader = blogDB.GetBlogStats(ModuleID);
                try
                {
                    if (dataReader.Read())
                    {
                        lblEntryCount.Text = Esperantus.Localize.GetString("BLOG_ENTRIES", "Entries", null) +
                                             " (" + (string)dataReader["EntryCount"].ToString() + ")";
                        lblCommentCount.Text = Esperantus.Localize.GetString("BLOG_COMMENTS", "Comments", null) +
                                               " (" + (string)dataReader["CommentCount"].ToString() + ")";
                    }
                }
                finally
                {
                    dataReader.Close();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of Blog information from the Blogs
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the Rainbow.BlogDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Added EsperantusKeys for Localization
            // Mario Endara [email protected] june-1-2004
            Feedback = Esperantus.Localize.GetString("BLOG_FEEDBACK");

            if (!IsPostBack)
            {
                lnkRSS.HRef       = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Blog/RSS.aspx", TabID, "&mID=" + ModuleID);
                imgRSS.Src        = Rainbow.HttpUrlBuilder.BuildUrl("~/DesktopModules/Blog/xml.gif");
                lblCopyright.Text = Settings["Copyright"].ToString();
                // Obtain Blogs information from the Blogs table
                // and bind to the datalist control
                BlogDB blogData = new BlogDB();
                myDataList.DataSource = blogData.GetBlogs(ModuleID);
                myDataList.DataBind();

                dlArchive.DataSource = blogData.GetBlogMonthArchive(ModuleID);
                dlArchive.DataBind();

                SqlDataReader dr = blogData.GetBlogStats(ModuleID);
                try
                {
                    if (dr.Read())
                    {
                        lblEntryCount.Text = Esperantus.Localize.GetString("BLOG_ENTRIES", "Entries", null) +
                                             " (" + (string)dr["EntryCount"].ToString() + ")";
                        lblCommentCount.Text = Esperantus.Localize.GetString("BLOG_COMMENTS", "Comments", null) +
                                               " (" + (string)dr["CommentCount"].ToString() + ")";
                    }
                }
                finally
                {
                    // close the datareader
                    dr.Close();
                }
            }
        }
Ejemplo n.º 3
0
        private void RenderRSS(int moduleID)
        {
            /*
             *
             * For more info on RSS 2.0
             * http://www.feedvalidator.org/docs/rss2.html
             *
             * Fields not implemented yet:
             * <blogChannel:blogRoll>http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml</blogChannel:blogRoll>
             * <blogChannel:mySubscriptions>http://radio.weblogs.com/0001015/gems/mySubscriptions.opml</blogChannel:mySubscriptions>
             * <blogChannel:blink>http://diveintomark.org/</blogChannel:blink>
             * <lastBuildDate>Mon, 30 Sep 2002 11:00:00 GMT</lastBuildDate>
             * <docs>http://backend.userland.com/rss</docs>
             *
             */

            Response.ContentType = "text/xml";

            Hashtable moduleSettings = ModuleSettings.GetModuleSettings(moduleID);
            Encoding  encoding       = new UTF8Encoding();

            XmlTextWriter xmlTextWriter = new XmlTextWriter(Response.OutputStream, encoding);

            xmlTextWriter.Formatting = Formatting.Indented;

            xmlTextWriter.WriteStartDocument();
            xmlTextWriter.WriteComment("RSS generated by Rainbow Portal Blog Module V 1.0 on " + DateTime.Now.ToLongDateString());
            xmlTextWriter.WriteStartElement("rss");

            xmlTextWriter.WriteStartAttribute("version", "http://rainbowportal.net/blogmodule");
            xmlTextWriter.WriteString("2.0");
            xmlTextWriter.WriteEndAttribute();

            xmlTextWriter.WriteStartElement("channel");

            /*
             *      RSS 2.0
             *      Required elements for channel are title link and description
             */
            xmlTextWriter.WriteStartElement("title");
            try
            {
                xmlTextWriter.WriteString(moduleSettings["MODULESETTINGS_TITLE_en-US"].ToString());
            }
            catch
            {
                //HACK: Get MODULESETTINGS_TITLE from where?
                xmlTextWriter.WriteString("Rainbow Blog");
            }
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("link");
            xmlTextWriter.WriteString(Request.Url.ToString().Replace("DesktopModules/Blog/RSS.aspx", "DesktopDefault.aspx"));
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("description");
            xmlTextWriter.WriteString(moduleSettings["Description"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("copyright");
            xmlTextWriter.WriteString(moduleSettings["Copyright"].ToString());
            xmlTextWriter.WriteEndElement();

            // begin optional RSS 2.0 fields

            //ttl = time to live in minutes, how long a channel can be cached before refreshing from the source
            xmlTextWriter.WriteStartElement("ttl");
            xmlTextWriter.WriteString(moduleSettings["RSS Cache Time In Minutes"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("managingEditor");
            xmlTextWriter.WriteString(moduleSettings["Author Email"].ToString());
            xmlTextWriter.WriteEndElement();

            xmlTextWriter.WriteStartElement("language");
            xmlTextWriter.WriteString(moduleSettings["Language"].ToString());
            xmlTextWriter.WriteEndElement();


            if (ConfigurationSettings.AppSettings.Get("webMaster") != null)
            {
                xmlTextWriter.WriteStartElement("webMaster");
                xmlTextWriter.WriteString(ConfigurationSettings.AppSettings.Get("webMaster"));
                xmlTextWriter.WriteEndElement();
            }
            xmlTextWriter.WriteStartElement("generator");
            xmlTextWriter.WriteString("Rainbow Portal Blog Module V 1.0");
            xmlTextWriter.WriteEndElement();

            BlogDB        blogDB = new BlogDB();
            SqlDataReader dr     = blogDB.GetBlogs(moduleID);

            try
            {
                //write channel items
                while (dr.Read())
                {
                    //beginning of blog entry
                    xmlTextWriter.WriteStartElement("item");

                    /*
                     * RSS 2.0
                     * All elements of an item are optional, however at least one of title or description
                     * must be present.
                     */

                    xmlTextWriter.WriteStartElement("title");
                    xmlTextWriter.WriteString(dr["Title"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("link");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("pubDate");
                    xmlTextWriter.WriteString(DateTime.Parse(dr["StartDate"].ToString()).ToString("dddd MMMM d yyyy hh:mm:ss tt zzz"));
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("guid");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("comments");
                    xmlTextWriter.WriteString(Request.Url.ToString().Replace("RSS.aspx", "blogview.aspx") + "&ItemID=" + dr["ItemID"].ToString());
                    xmlTextWriter.WriteEndElement();

                    xmlTextWriter.WriteStartElement("description");
                    xmlTextWriter.WriteCData(Server.HtmlDecode((string)dr["Description"].ToString()));
                    xmlTextWriter.WriteEndElement();


                    //end blog entry
                    xmlTextWriter.WriteEndElement();
                }
            }
            finally
            {
                dr.Close();
            }

            //end of document
            xmlTextWriter.WriteEndElement();
            xmlTextWriter.Close();
        }