示例#1
0
        newtelligence.DasBlog.Web.Services.MetaWeblog.Post[] IMetaWeblog.metaweblog_getRecentPosts(string blogid, string username, string password, int numberOfPosts)
        {
            if ( !siteConfig.EnableBloggerApi )
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);
            if (token == null)
            {
                throw new System.Security.SecurityException();
            }

            EntryCollection entries = dataService.GetEntriesForDay( DateTime.Now.ToUniversalTime(), new Util.UTCTimeZone(), null, SiteConfig.GetSiteConfig().RssDayCount, numberOfPosts, null );
            ArrayList arrayList = new ArrayList();
            foreach (Entry entry in entries)
            {
                newtelligence.DasBlog.Web.Services.MetaWeblog.Post post = new newtelligence.DasBlog.Web.Services.MetaWeblog.Post();
                post.description=noNull(entry.Content);
                post.dateCreated=entry.CreatedUtc;
                post.title = noNull(entry.Title);
                post.link = post.permalink = SiteUtilities.GetPermaLinkUrl(entry);
                post.postid = noNull(entry.EntryId);
                post.categories = entry.GetSplitCategories();
                arrayList.Add( post );
            }
            return arrayList.ToArray(typeof(newtelligence.DasBlog.Web.Services.MetaWeblog.Post)) as newtelligence.DasBlog.Web.Services.MetaWeblog.Post[];
        }
示例#2
0
        newtelligence.DasBlog.Web.Services.MetaWeblog.Post IMetaWeblog.metaweblog_getPost(string postid, string username, string password)
        {
            if ( !siteConfig.EnableBloggerApi )
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);
            if (token == null)
            {
                throw new System.Security.SecurityException();
            }

            Entry entry = dataService.GetEntry( postid );
            if ( entry != null )
            {
                newtelligence.DasBlog.Web.Services.MetaWeblog.Post post = new newtelligence.DasBlog.Web.Services.MetaWeblog.Post();
                post.description = noNull(entry.Content);
                post.dateCreated = entry.CreatedUtc;
                post.title = noNull(entry.Title);
                post.link = post.permalink = SiteUtilities.GetPermaLinkUrl(entry);
                post.postid = noNull(entry.EntryId);
                post.categories = entry.GetSplitCategories();

                return post;
            }
            else
            {
                return new newtelligence.DasBlog.Web.Services.MetaWeblog.Post();
            }
        }
示例#3
0
        /// <summary>Fills a DasBlog entry from a MetaWeblog Post structure.</summary>
        /// <param name="entry">DasBlog entry to fill.</param>
        /// <param name="post">MetaWeblog post structure to fill from.</param>
        /// <returns>TrackbackInfoCollection of posts to send trackback pings.</returns>
        private TrackbackInfoCollection FillEntryFromMetaWeblogPost(Entry entry, newtelligence.DasBlog.Web.Services.MetaWeblog.Post post)
        {
            // W.Bloggar doesn't pass in the DataCreated,
            // so we have to check for that
            if (post.dateCreated != DateTime.MinValue)
            {
                entry.CreatedUtc = post.dateCreated.ToUniversalTime();
            }

            //Patched to avoid html entities in title
            entry.Title       = HttpUtility.HtmlDecode(post.title);
            entry.Content     = post.description;
            entry.Description = noNull(post.mt_excerpt);

            // If mt_allow_comments is null, then the sender did not specify.  Use default dasBlog behavior in that case
            if (post.mt_allow_comments != null)
            {
                int nAllowComments = Convert.ToInt32(post.mt_allow_comments);
                if (nAllowComments == 0 || nAllowComments == 2)
                {
                    entry.AllowComments = false;
                }
                else
                {
                    entry.AllowComments = true;
                }
            }

            if (post.categories != null && post.categories.Length > 0)
            {
                // handle categories
                string categories = "";

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                bool needSemi = false;
                post.categories = RemoveDups(post.categories, true);
                foreach (string category in post.categories)
                {
                    //watch for "" as a category
                    if (category.Length > 0)
                    {
                        if (needSemi)
                        {
                            sb.Append(";");
                        }
                        sb.Append(category);
                        needSemi = true;
                    }
                }
                categories = sb.ToString();

                if (categories.Length > 0)
                {
                    entry.Categories = categories;
                }
            }

            // We'll always return at least an empty collection
            TrackbackInfoCollection trackbackList = new TrackbackInfoCollection();

            // Only MT supports trackbacks in the post
            if (post.mt_tb_ping_urls != null)
            {
                foreach (string trackbackUrl in post.mt_tb_ping_urls)
                {
                    trackbackList.Add(new TrackbackInfo(
                                          trackbackUrl,
                                          SiteUtilities.GetPermaLinkUrl(siteConfig, (ITitledEntry)entry),
                                          entry.Title,
                                          entry.Description,
                                          siteConfig.Title));
                }
            }
            return(trackbackList);
        }
示例#4
0
        /// <summary>
        /// Creates a <see cref="MetaWeblog.Post"/> from an <see cref="Entry"/>.
        /// </summary>
        /// <param name="entry">The entry.</param>
        /// <returns></returns>
        public static Post Create(Entry entry)
        {
            if (entry == null) throw new ArgumentNullException("entry");

            Post post = new Post();
            post.description = entry.Content ?? "";
            post.mt_excerpt = entry.Description ?? "";
            post.dateCreated = entry.CreatedUtc;
            post.title = entry.Title ?? "";
            post.link = post.permalink = SiteUtilities.GetPermaLinkUrl(entry);
            post.postid = entry.EntryId ?? "";
            post.categories = entry.GetSplitCategories();
            return post;
        }
示例#5
0
        string IMetaWeblog.metaweblog_newPost(string blogid, string username, string password, newtelligence.DasBlog.Web.Services.MetaWeblog.Post post, bool publish)
        {
            if (!siteConfig.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = SiteSecurity.Login(username, password);

            if (token == null)
            {
                throw new System.Security.SecurityException();
            }

            Entry newPost = new Entry();

            newPost.Initialize();
            newPost.Author = username;

            TrackbackInfoCollection trackbackList = FillEntryFromMetaWeblogPost(newPost, post);

            newPost.IsPublic   = publish;
            newPost.Syndicated = publish;
            // give the XSS upstreamer a hint that things have changed
            //FIX: XSSUpstreamer.TriggerUpstreaming();

            SiteUtilities.SaveEntry(newPost, trackbackList, siteConfig, this.logService, this.dataService);

            return(newPost.EntryId);
        }