Exemplo n.º 1
0
 protected void dlComments_ItemCommand(object source, DataListCommandEventArgs e)
 {
     if (e.CommandName == "DeleteComment")
     {
         BlogDB blogDB = new BlogDB();
         blogDB.DeleteBlogComment(int.Parse(e.CommandArgument.ToString()));
         Response.Clear();
         Response.Redirect(Request.Url.ToString());
     }
 }
Exemplo n.º 2
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();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The BindData method is used to obtain details of a message
        /// from the Blogs table, and update the page with
        /// the message content.
        /// </summary>
        void BindData()
        {
            // Obtain the selected item from the Blogs table
            BlogDB        blogDB     = new BlogDB();
            SqlDataReader dataReader = blogDB.GetSingleBlog(ItemID);

            try
            {
                // Load first row from database
                if (dataReader.Read())
                {
                    // Update labels with message contents
                    Title.Text       = (string)dataReader["Title"].ToString();
                    txtTitle.Text    = "re: " + (string)dataReader["Title"].ToString();
                    StartDate.Text   = ((DateTime)dataReader["StartDate"]).ToString("dddd MMMM d yyyy hh:mm tt");
                    Description.Text = Server.HtmlDecode((string)dataReader["Description"].ToString());
                }
            }
            finally
            {
                dataReader.Close();
            }
            dlComments.DataSource = blogDB.GetBlogComments(ModuleID, ItemID);
            dlComments.DataBind();

            if (Request.Params.Get("blogUser") != null)
            {
                this.txtName.Text = Request.Params.Get("blogUser");
            }
            if (Request.Params.Get("blogUrl") != null)
            {
                this.txtURL.Text = Request.Params.Get("blogUrl");
            }

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

            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();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// The DeleteBtn_Click event handler on this Page is used to delete an
 /// a Blog.  It  uses the Rainbow.BlogsDB()
 /// data component to encapsulate all data functionality.
 /// </summary>
 /// <param name="e"></param>
 override protected void OnDelete(EventArgs e)
 {
     base.OnDelete(e);
     // Only attempt to delete the item if it is an existing item
     // (new items will have "ItemID" of 0)
     if (ItemID != 0)
     {
         BlogDB blogData = new BlogDB();
         blogData.DeleteBlog(ItemID);
     }
     this.RedirectBackToReferringPage();
 }
Exemplo n.º 5
0
 protected void btnPostComment_Click(object sender, System.EventArgs e)
 {
     if (IsValidComment())
     {
         if (this.chkRememberMe.Checked)
         {
             SetCookies();
         }
         BlogDB blogDB = new BlogDB();
         blogDB.AddBlogComment(ModuleID, ItemID, this.txtName.Text,
                               this.txtTitle.Text, this.txtURL.Text, this.txtComments.Text);
         Response.Redirect(Request.Url.ToString());
     }
 }
Exemplo n.º 6
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();
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Is used to either create or update an Blog.
        /// It uses the Rainbow.BlogsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        override protected void OnUpdate(EventArgs e)
        {
            base.OnUpdate(e);

            // Only Update if Input Data is Valid
            if (Page.IsValid == true)
            {
                BlogDB blogData = new BlogDB();
                // Provide Excerpt if not present
                if (ExcerptField.Text == string.Empty)
                {
                    ExcerptField.Text = ((HTMLText)DesktopText.Text).GetAbstractText(100);
                }
                if (ItemID == 0)
                {
                    blogData.AddBlog(ModuleID, PortalSettings.CurrentUser.Identity.Email, ((HTMLText)TitleField.Text).InnerText, ((HTMLText)ExcerptField.Text).InnerText, Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), true);
                }
                else
                {
                    blogData.UpdateBlog(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, ((HTMLText)TitleField.Text).InnerText, ((HTMLText)ExcerptField.Text).InnerText, Server.HtmlEncode(DesktopText.Text), DateTime.Parse(StartField.Text), true);
                }
                this.RedirectBackToReferringPage();
            }
        }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
        /// <summary>
        /// Author:					Joe Audette
        /// Created:				1/18/2004
        /// Last Modified:			2/5/2004
        ///
        /// The Page_Load event on this Page is used to obtain the ModuleID
        /// and ItemID of the Blog Entry to edit.
        /// It then uses the Rainbow.BlogDB() data component
        /// to populate the page's edit controls with the Blog Entry details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Add the setting
            HtmlEditorDataType h = new HtmlEditorDataType();

            h.Value     = moduleSettings["Editor"].ToString();
            DesktopText = h.GetEditor(PlaceHolderHTMLEditor, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings);
            // Construct the page
            DesktopText.Width  = new System.Web.UI.WebControls.Unit(moduleSettings["Width"].ToString());
            DesktopText.Height = new System.Web.UI.WebControls.Unit(moduleSettings["Height"].ToString());
            // Construct the page
            // Added css Styles by Mario Endara <*****@*****.**> (2004/10/26)
            updateButton.CssClass = "CommandButton";
            PlaceHolderButtons.Controls.Add(updateButton);
            PlaceHolderButtons.Controls.Add(new LiteralControl("&#160;"));
            cancelButton.CssClass = "CommandButton";
            PlaceHolderButtons.Controls.Add(cancelButton);
            PlaceHolderButtons.Controls.Add(new LiteralControl("&#160;"));
            deleteButton.CssClass = "CommandButton";
            PlaceHolderButtons.Controls.Add(deleteButton);
            // If the page is being requested the first time, determine if an
            // Blog itemID value is specified, and if so populate page
            // contents with the Blog details
            if (Page.IsPostBack == false)
            {
                if (ItemID != 0)
                {
                    BlogDB        blogData = new BlogDB();
                    SqlDataReader dr       = blogData.GetSingleBlog(ItemID);
                    try
                    {
                        // Load first row into Datareader
                        if (dr.Read())
                        {
                            StartField.Text   = ((DateTime)dr["StartDate"]).ToString();
                            TitleField.Text   = (string)dr["Title"].ToString();
                            ExcerptField.Text = (string)dr["Excerpt"].ToString();
                            DesktopText.Text  = Server.HtmlDecode(dr["Description"].ToString());
                            CreatedBy.Text    = (string)dr["CreatedByUser"].ToString();
                            CreatedDate.Text  = ((DateTime)dr["CreatedDate"]).ToString();

                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedBy.Text == "unknown")
                            {
                                CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                }
                else
                {
                    //New article - set defaults
                    StartField.Text  = DateTime.Now.ToString();
                    CreatedBy.Text   = PortalSettings.CurrentUser.Identity.Email;
                    CreatedDate.Text = DateTime.Now.ToString();
                }
            }
        }