dev.net.ua

Українська Спільнота Розробникiв
 
Ласкаво просимо до dev.net.ua Увійти | Приєднатися | Допомога | Увійти Live ID
в Пошук

Пост с исходниками

Останнє повідомлення 29-08-2006, 10:33 від George J. Capnias. 2 відповіді.
Сортувати: Попереднє Наступне
  •  28-08-2006, 17:51 22

    Пост с исходниками

    Исходник на VB

    URL to this post: http://dev.net.ua/forums/thread/22.aspx

      Function StripHTML(ByVal htmlString As String) As String
        Dim pattern As String = "<(.|\n)*?>"
        Dim options As RegexOptions = ((RegexOptions.IgnorePatternWhitespace Or RegexOptions.Multiline) Or RegexOptions.IgnoreCase)
        Dim re As Regex = New Regex(pattern, options)
        ' Add your code here
        Return re.Replace(htmlString.ToString(), " ")
      End Function
      Function TruncateQuoteAt(ByVal quoteString As String, ByVal maxLen As Integer, Optional ByVal detailsUrl As String = "") As String
        Dim returnString As String = quoteString
        If quoteString.Length > maxLen Then
          returnString = quoteString.Substring(0, maxLen) + " ..."
          If detailsUrl <> "" Then returnString = returnString + " [&nbsp;<a href=""" + detailsUrl + """>read&nbsp;more</a>&nbsp;]"
        End If
        Return returnString
      End Function


    Thank you,
    Serge Baranovsky
    Microsoft MVP   |   http://submain.com - .NET Developer Tools   |   http://vbcity.com - Visual Basic Developer Community

    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  28-08-2006, 22:51 23 у відповідь на 22

    Re: Пост с исходниками

    Once more

      Function StripHTML(ByVal htmlString As String) As String

        Dim pattern As String = "<(.|\n)*?>"
        Dim options As RegexOptions = ((RegexOptions.IgnorePatternWhitespace Or RegexOptions.Multiline) Or RegexOptions.IgnoreCase)
        Dim re As Regex = New Regex(pattern, options)

        ' Add your code here
        Return re.Replace(htmlString.ToString(), " ")
      End Function

      Function TruncateQuoteAt(ByVal quoteString As String, ByVal maxLen As Integer, Optional ByVal detailsUrl As String = "") As String

        Dim returnString As String = quoteString

        If quoteString.Length > maxLen Then
          returnString = quoteString.Substring(0, maxLen) + " ..."

          If detailsUrl <> "" Then returnString = returnString + " [&nbsp;<a href=""" + detailsUrl + """>read&nbsp;more</a>&nbsp;]"
        End If

        Return returnString

      End Function


    Thank you,
    Serge Baranovsky
    Microsoft MVP   |   http://submain.com - .NET Developer Tools   |   http://vbcity.com - Visual Basic Developer Community

    » » C#/VB .NET Coding Guidelines - FREE 100+ page ebook (PDF) http://submain.com/guidelines
  •  29-08-2006, 10:33 24 у відповідь на 23

    Re: Пост с исходниками



    using System;
    using System.Web.UI.WebControls;
    using CommunityServer;
    using CommunityServer.Components;
    using CommunityServer.Controls;
    using CommunityServer.Blogs;
    using CommunityServer.Blogs.Components;
    using CommunityServer.CMS;

    namespace CommunityServer.CMS {
     /// <summary>
     /// Represents an in memory aggregate list of blog posts for a specific weblog.
     /// </summary>
     public class BlogPosts : TemplatedWebControl {

      #region " Constructor "
      /// <summary>
      /// BlogPosts constructor.
      /// </summary>
      public BlogPosts() : base() {
       //
       // TODO: Add constructor logic here
       //
      }

      #endregion

      #region " Properties "
      private AggregateListBlogPosts blogPostsList = null;
      private Weblog thisWeblog = null;

      #region " Control Properties "
      private bool _showBody = false;
      /// <summary>
      /// Gets or sets a value indicating whether to show the body of a post.
      /// </summary>
      public bool ShowBody {
       set {
        this._showBody = value;
       }
       get {
        return this._showBody;
       }
      }

      private bool _showIcons = false;
      /// <summary>
      /// Gets or sets a value indicating if icon of the blog post/article is visible.
      /// </summary>
      public bool ShowIcons {
       set {
        this._showIcons = value;
       }
       get {
        return this._showIcons;
       }
      }

      private bool _collapsed;
      /// <summary>
      /// Gets or sets a value indicating if the panel is collapsed.
      /// </summary>
      public bool Collapsed{
       get {
        return _collapsed;
       }
       set {
        _collapsed = value;
       }
      }

      #endregion

      #region " Query Properties "
      private string _blogID;
      /// <summary>
      /// Gets or sets an value that represents the blog key.
      /// </summary>
      public string BlogID {
       set {
        _blogID = value;
       }
       get {
        return _blogID;
       }
      }

      private int _timeFrame = 60;
      /// <summary>
      /// Gets or sets a value that represents the timeframe in days the query for the recent post will use.
      /// </summary>
      public int TimeFrame {
       set {
        this._timeFrame = value;
       }
       get {
        return this._timeFrame;
       }
      }

      private SortOrder _SortingOrder = SortOrder.Descending;
      /// <summary>
      /// Gets or sets an enum that represents the sorting of post threads.
      /// </summary>
      public SortOrder SortingOrder {
       set {
        this._SortingOrder = (SortOrder) value;
       }
       get {
        return this._SortingOrder;
       }
      }

      #endregion

      #region " Pager Properties "

      private bool _enablePager = false;
      /// <summary>
      /// Gets or sets a value indicating if the pager would be visible.
      /// </summary>
      public bool EnablePager {
       get {
        return _enablePager;
       }
       set {
        _enablePager = value;
       }
      }

      private int _pageSize = 10;
      /// <summary>
      /// Gets or sets a value that represents the pagesize of the post listed.
      /// </summary>
      public int PageSize {
       get {
        return _pageSize;
       }
       set {
        _pageSize = value;
       }
      }

      #endregion

      #endregion

      #region " Overrides "
      /// <summary>
      /// Overridden. See TemplatedWebControl.ExternalSkinFileName
      /// </summary>
      protected override string ExternalSkinFileName {
       get {
        return CreateExternalSkinFileName("CMS");
       }
      }

      
      /// <summary>
      /// Overridden. See TemplatedWebControl.AttachChildControls
      /// </summary>
      protected override void AttachChildControls() {
       blogPostsList = FindControl("PostsList") as AggregateListBlogPosts;
       blogPostsList.ShowBody = this.ShowBody;
       blogPostsList.ShowIcons = this.ShowIcons;
       blogPostsList.Collapsed = this.Collapsed;

       thisWeblog = Weblogs.GetWeblog(this.BlogID);
       if (thisWeblog != null){
        blogPostsList.Title = thisWeblog.Name;
       }
       
       blogPostsList.View = CMS.AggregateListBlogPosts.ViewType.IsRecent;
       blogPostsList.EnablePager = this.EnablePager;
       blogPostsList.PageSize = this.PageSize;
       blogPostsList.RSSLink = BlogUrls.Instance().Rss(thisWeblog.ApplicationKey);

       blogPostsList.PagerIndexChanged +=new EventHandler(blogPosts_PagerIndexChanged);

       this.DataBind();

      }

      /// <summary>
      /// Overridden. See TemplatedWebControl.DataBind
      /// </summary>
      public override void DataBind() {
       base.DataBind ();
       blogPostsList.PageSize = this.PageSize;

       BlogThreadQuery query = new BlogThreadQuery();
       query.BlogID = thisWeblog.SectionID;
       query.DateFilter=DateTime.Now.AddDays(this.TimeFrame * -1);
       query.BlogPostType = BlogPostType.Post;
       query.BlogThreadType = BlogThreadType.Recent;
       query.IncludeCategories = false;
       query.IsPublished = true;
       query.PageIndex = blogPostsList.PageIndex;
       query.PageSize = blogPostsList.PageSize;
       query.IgnorePaging = false;
       query.SortBy = BlogThreadSortBy.MostRecent;
       query.SortOrder = this.SortingOrder;
       query.PostConfig = BlogPostConfig.IsCommunityAggregated | BlogPostConfig.IsAggregated;
       query.FilterByList = Sections.FilterByAccessControl(Weblogs.GetWeblogs(false, true, false), Permission.View);

       ThreadSet ts = WeblogPosts.GetBlogThreads(query, true, true);
       if (ts.TotalRecords == 0) {
        this.Visible = false;
       }
      
       blogPostsList.DataSource = ts.Threads;
       blogPostsList.DataBind();
       blogPostsList.TotalRecords = ts.TotalRecords;
      }

      /// <summary>
      /// RenderBeginTag implementation
      /// </summary>
      /// <param name="writer"></param>
      public override void RenderBeginTag(System.Web.UI.HtmlTextWriter writer) {
       // No beginning tag
      }

      /// <summary>
      /// RenderEndTag implementation
      /// </summary>
      /// <param name="writer"></param>
      public override void RenderEndTag(System.Web.UI.HtmlTextWriter writer) {
       // No ending tag
      }

      #endregion
     
      #region " Private "

      /// <summary>
      /// Event Handler for blogPostsList.PagerIndexChanged
      /// </summary>
      /// <param name="sender"></param>
      /// <param name="e"></param>
      private void blogPosts_PagerIndexChanged(object sender, EventArgs e) {
       this.DataBind();
      }

      #endregion
     
     }
    }

Переглядати як новосний Блог RSS в XML