Beispiel #1
0
        public MetaWeblog.CategoryInfo[] metaweblog_getCategories(string blogid, string username, string password)
        {
            if (!_dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }
            UserToken token = _siteSecurity.Login(username, password);

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

            List <MetaWeblog.CategoryInfo> arrayList  = new List <MetaWeblog.CategoryInfo>();
            CategoryCacheEntryCollection   categories = _dataService.GetCategories();

            if (categories.Count == 0)
            {
                MetaWeblog.CategoryInfo bcat = new MetaWeblog.CategoryInfo();
                bcat.categoryid  = "Front Page";
                bcat.description = "Front Page";
                bcat.htmlUrl     = _dasBlogSettings.GetCategoryViewUrl(bcat.categoryid);
                bcat.rssUrl      = _dasBlogSettings.GetCategoryViewUrl(bcat.categoryid); // TODO should this be GetRssCategoryUrl
                bcat.title       = NoNull(bcat.description);
                arrayList.Add(bcat);
            }
            else
            {
                foreach (CategoryCacheEntry cat in categories)
                {
                    MetaWeblog.CategoryInfo bcat = new MetaWeblog.CategoryInfo();
                    bcat.categoryid  = NoNull(cat.Name);
                    bcat.description = NoNull(cat.Name);
                    bcat.htmlUrl     = _dasBlogSettings.GetCategoryViewUrl(cat.Name);
                    bcat.rssUrl      = _dasBlogSettings.GetCategoryViewUrl(cat.Name); // TODO should this be GetRssCategoryUrl
                    bcat.title       = NoNull(cat.Name);
                    arrayList.Add(bcat);
                }
            }
            return(arrayList.ToArray());
        }
Beispiel #2
0
        public MetaWeblog.CategoryInfo[] metaweblog_getCategories(string blogid, string username, string password)
        {
            if (!dasBlogSettings.SiteConfiguration.EnableBloggerApi)
            {
                throw new ServiceDisabledException();
            }

            if (!VerifyLogin(username, password))
            {
                throw new SecurityException();
            }

            var arrayList  = new List <MetaWeblog.CategoryInfo>();
            var categories = dataService.GetCategories();

            if (categories.Count == 0)
            {
                var bcat = new MetaWeblog.CategoryInfo();
                bcat.categoryid  = "Front Page";
                bcat.description = "Front Page";
                bcat.htmlUrl     = dasBlogSettings.GetCategoryViewUrl(bcat.categoryid);
                bcat.rssUrl      = dasBlogSettings.GetRssCategoryUrl(bcat.categoryid);
                bcat.title       = NoNull(bcat.description);
                arrayList.Add(bcat);
            }
            else
            {
                foreach (CategoryCacheEntry cat in categories)
                {
                    var bcat = new MetaWeblog.CategoryInfo();
                    bcat.categoryid  = NoNull(cat.Name);
                    bcat.description = NoNull(cat.Name);
                    bcat.htmlUrl     = dasBlogSettings.GetCategoryViewUrl(cat.Name);
                    bcat.rssUrl      = dasBlogSettings.GetRssCategoryUrl(cat.Name);
                    bcat.title       = NoNull(cat.Name);
                    arrayList.Add(bcat);
                }
            }
            return(arrayList.ToArray());
        }