Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="blogPostCommentId"></param>
        void GetBlogPost(long siteId, long blogPostId)
        {
            DateTime now = DateTime.Now;

            AWAPI_Data.CustomEntities.BlogPostExtended blogPost = _blogLib.GetBlogPost(blogPostId);
            if (blogPost == null || blogPost.siteId != siteId ||
                !blogPost.Blog.isEnabled || !blogPost.isPublished)
            {
                return;
            }

            if (blogPost.pubDate != null && blogPost.pubDate > now ||
                blogPost.pubEndDate != null && blogPost.pubEndDate < now)
            {
                return;
            }

            _feed.AttributeExtensions.Add(new XmlQualifiedName("blogtitle"), blogPost.Blog.title);

            GetPostPageBaseUrl(blogPost.Blog.blogPostPage);

            List <SyndicationItem> items    = new List <SyndicationItem>();
            string          postPageBaseUrl = GetPostPageBaseUrl(blogPost.Blog.blogPostPage);
            SyndicationItem blogitem        = CreateBlogPostSyndicationItem(blogPost, postPageBaseUrl);

            items.Add(blogitem);

            _feed.Items = items;
        }
Пример #2
0
        void PopulateBlogPost(Int64 blogPostId)
        {
            ResetControls();
            AWAPI_Data.CustomEntities.BlogPostExtended blogPost = _blogLib.GetBlogPost(blogPostId);

            if (blogPost == null)
            {
                return;
            }

            if (_blogId <= 0)
            {
                _blogId = blogPost.blogId;
            }

            _id.Text           = blogPost.blogPostId.ToString();
            _title.Text        = blogPost.title;
            _summary.Text      = blogPost.summary;
            _description.Value = blogPost.description;

            _isPublished.Checked = blogPost.isPublished;
            _imageUrl.Text       = blogPost.imageurl;

            SetImage(blogPost.imageurl);

            _isCommentable.Checked = blogPost.isCommentable;

            if (blogPost.pubDate != null)
            {
                _pubDate.Text = blogPost.pubDate.Value.ToString("MM/dd/yyyy HH:mm");
            }
            if (blogPost.pubEndDate != null)
            {
                _pubEndDate.Text = blogPost.pubEndDate.Value.ToString("MM/dd/yyyy HH:mm");
            }

            if (_authorList.Items.FindByValue(blogPost.authorUserId.ToString()) != null)
            {
                _authorList.SelectedValue = blogPost.authorUserId.ToString();
            }
            else if (_authorList.Items.FindByValue(blogPost.userId.ToString()) != null)
            {
                _authorList.SelectedValue = blogPost.userId.ToString();
            }
            else
            {
                _authorList.SelectedIndex = 0;
            }

            SelectCategories(blogPost.blogPostId);
            SelectTags(blogPost.blogPostId);

            ShowHideContentButtons(true);
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (_blogId <= 0 && _idFromUrl > 0)
                {
                    AWAPI_Data.CustomEntities.BlogPostExtended blogPost = _blogLib.GetBlogPost(_idFromUrl);
                    if (blogPost == null)
                    {
                        return;
                    }

                    _blogId = blogPost.blogId;
                }

                ResetControls();
                PopulateCategories();
                PopulateTags();
                PopulateAuthorList();

                if (_idFromUrl > 0)
                {
                    PopulateBlogPost(_idFromUrl);
                }

                PopulateBlogInfo();
                PopulateBlogPostList();

                if (Request["commentid"] != null && _idFromUrl >= 0)
                {
                    System.Text.StringBuilder script = new System.Text.StringBuilder();
                    script.Append("$(document).ready(function(){ \n");
                    script.Append("    $.fn.colorbox({href:'frames/blogpostcomments.aspx?postid=" + _idFromUrl.ToString() +
                                  "&commentid=" + Request["commentid"] + "', open:true, width:'960px', height:'600px', iframe:true});");
                    script.Append("}); \n");
                    RegisterCustomScript(script);
                }
            }

            RegisterCustomScript();
            AddScriptToCategoryList();
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        SyndicationItem CreateBlogPostFileSyndicationItem(AWAPI_Data.CustomEntities.BlogPostExtended blogPost, AWAPI_Data.Data.awFile_Blog file, string pageUrlBase)
        {
            Uri uri = null;

            if (!String.IsNullOrEmpty(pageUrlBase))
            {
                uri = new Uri(pageUrlBase + "?blogid=" + BlogId + "&postid=" + blogPost.blogPostId.ToString());
            }

            //SyndicationItem item = new SyndicationItem(
            //                    AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(file.title, MaximumTitleLength)),
            //                    AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(file.description, MaximumDescLength)),
            //                    uri,
            //                    file.fileId.ToString(),
            //                    file.lastBuildDate.Value);

            SyndicationItem item = new SyndicationItem();

            item.Title           = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(file.title, MaximumTitleLength), TextSyndicationContentKind.Html);
            item.Content         = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(file.description, MaximumDescLength), TextSyndicationContentKind.Html);
            item.LastUpdatedTime = file.lastBuildDate.Value;
            item.BaseUri         = uri;
            item.Id = file.fileId.ToString();

            item.ElementExtensions.Add("fileurl", null, AWAPI_BusinessLibrary.library.ConfigurationLibrary.Config.fileServiceUrl + "?id=" + file.fileId.ToString());
            item.ElementExtensions.Add("contenttype", null, file.contentType);
            if (file.isOnLocal)
            {
                item.ElementExtensions.Add("fileoriginalurl", null, AWAPI_BusinessLibrary.library.ConfigurationLibrary.Config.fileServiceUrl + "?id=" + file.fileId.ToString());
            }
            else
            {
                item.ElementExtensions.Add("fileoriginalurl", null, file.path);
            }

            return(item);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="blogId"></param>
        void GetBlogPostFileList(long siteId, long blogPostId)
        {
            AWAPI_Data.CustomEntities.BlogPostExtended blogPost = _blogLib.GetBlogPost(blogPostId);

            //check if the blog post is available
            DateTime now = DateTime.Now;

            if (blogPost == null || blogPost.siteId != siteId ||
                !blogPost.Blog.isEnabled || !blogPost.isPublished)
            {
                return;
            }

            if (blogPost.pubDate != null && blogPost.pubDate > now ||
                blogPost.pubEndDate != null && blogPost.pubEndDate < now)
            {
                return;
            }

            IList <AWAPI_Data.Data.awFile_Blog> fileList = _blogLib.GetBlogPostFileList(blogPostId);

            if (fileList == null || fileList.Count == 0)
            {
                return;
            }

            //create syndication items for each blog item
            string postPageBaseUrl       = GetPostPageBaseUrl(blogPost.Blog.blogPostPage);
            List <SyndicationItem> items = new List <SyndicationItem>();

            foreach (AWAPI_Data.Data.awFile_Blog file in fileList)
            {
                SyndicationItem item = CreateBlogPostFileSyndicationItem(blogPost, file, postPageBaseUrl);
                items.Add(item);
            }
            _feed.Items = items;
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        SyndicationItem CreateBlogPostSyndicationItem(AWAPI_Data.CustomEntities.BlogPostExtended blogPost, string pageUrlBase)
        {
            Uri uri = null;

            if (!String.IsNullOrEmpty(pageUrlBase))
            {
                uri = new Uri(pageUrlBase + "?blogid=" + BlogId + "&postid=" + blogPost.blogPostId.ToString());
            }

            string summary = String.IsNullOrEmpty(blogPost.summary) ?
                             AWAPI_Common.library.MiscLibrary.EncodeHtml(AWAPI_Common.library.MiscLibrary.CropSentence(blogPost.description, 200)) :
                             blogPost.summary;

            SyndicationItem item = new SyndicationItem();

            item.Title           = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(blogPost.title, MaximumTitleLength), TextSyndicationContentKind.Html);
            item.Content         = new TextSyndicationContent(AWAPI_Common.library.MiscLibrary.CropSentence(blogPost.description, MaximumDescLength), TextSyndicationContentKind.Html);
            item.LastUpdatedTime = blogPost.lastBuildDate.Value;
            item.BaseUri         = uri;
            item.Id = blogPost.blogPostId.ToString();

            //new SyndicationItem(
            //                AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(blogPost.title, MaximumTitleLength)),
            //                AWAPI_Common.library.MiscLibrary.AddCDATA(AWAPI_Common.library.MiscLibrary.CropSentence(blogPost.description, MaximumDescLength)),
            //                uri,
            //                blogPost.blogPostId.ToString(),
            //                blogPost.lastBuildDate.Value);


            //new TextSyndicationContent("<b>Item Content</b>",TextSyndicationContentKind.Html


            item.ElementExtensions.Add("blogalias", null, blogPost.Blog.alias);
            item.ElementExtensions.Add("blogpostid", null, blogPost.blogPostId);
            item.ElementExtensions.Add("pubDate", null, blogPost.pubDate.Value);
            if (blogPost.geoTag != null)
            {
                item.ElementExtensions.Add("geotag", null, blogPost.geoTag);
            }
            item.ElementExtensions.Add("recommended", null, blogPost.recommended);
            item.ElementExtensions.Add("iscommentable", null, blogPost.isCommentable);
            item.ElementExtensions.Add("summary", null, summary);

            item.ElementExtensions.Add("userid", null, blogPost.userId);
            item.ElementExtensions.Add("username", null, blogPost.username);
            item.ElementExtensions.Add("useremail", null, blogPost.userEmail);
            item.ElementExtensions.Add("userfirstname", null, blogPost.userFirstName);
            item.ElementExtensions.Add("userlastname", null, blogPost.userLastName);
            if (blogPost.userImageUrl != null)
            {
                item.ElementExtensions.Add("userimageurl", null, blogPost.userImageUrl);
            }
            item.ElementExtensions.Add("numberofcomments", null, blogPost.numberOfComments);

            if (blogPost.createDate != null)
            {
                item.ElementExtensions.Add("createdate", null, blogPost.createDate);
            }
            if (blogPost.imageurl != null)
            {
                item.ElementExtensions.Add("imageurl", null, blogPost.imageurl);
            }

            if (blogPost.tags != null && blogPost.tags.Count() > 0)
            {
                IList <awBlogTag> tagList = blogPost.tags.ToList <awBlogTag>();
                foreach (awBlogTag tg in tagList)
                {
                    SyndicationCategory cat = new SyndicationCategory();
                    cat.AttributeExtensions.Add(new XmlQualifiedName("name"), "tags");
                    cat.AttributeExtensions.Add(new XmlQualifiedName("tagid"), tg.blogTagId.ToString());
                    cat.AttributeExtensions.Add(new XmlQualifiedName("tag"), tg.title.ToString());
                    item.Categories.Add(cat);
                }
            }

            return(item);
        }