From e9e2a86e2e68f52b8ee3f2e12fd6949638cd3920 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 20 Jul 2017 15:47:26 +1000 Subject: [PATCH] U4-5546 Remove user 'channels', weblog api, and all code / db tables relevant to those --- src/Umbraco.Web.UI/web.Template.Debug.config | 6 + src/Umbraco.Web.UI/web.Template.config | 6 - src/Umbraco.Web/Umbraco.Web.csproj | 18 - src/Umbraco.Web/packages.config | 1 - .../umbraco/channels/Blogger.cs | 161 ----- .../umbraco/channels/DocumentDateComparer.cs | 48 -- .../umbraco/channels/MetaWeblog.cs | 139 ----- .../umbraco/channels/UmbracoMetaWeblogAPI.cs | 568 ------------------ .../umbraco/channels/api.cs | 223 ------- .../umbraco/channels/config.cs | 239 -------- .../umbraco/channels/remixWeblogApi.cs | 90 --- .../umbraco/channels/rsd.aspx.cs | 22 - .../umbraco/channels/wlwmanifest.aspx.cs | 39 -- .../umbraco/channels/wordApi.cs | 32 - 14 files changed, 6 insertions(+), 1586 deletions(-) delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/Blogger.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/DocumentDateComparer.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/MetaWeblog.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/api.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/config.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/remixWeblogApi.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs delete mode 100644 src/Umbraco.Web/umbraco.presentation/umbraco/channels/wordApi.cs diff --git a/src/Umbraco.Web.UI/web.Template.Debug.config b/src/Umbraco.Web.UI/web.Template.Debug.config index 22cdd682fe..4b15922671 100644 --- a/src/Umbraco.Web.UI/web.Template.Debug.config +++ b/src/Umbraco.Web.UI/web.Template.Debug.config @@ -110,6 +110,8 @@ + + @@ -324,6 +326,10 @@ + + + + diff --git a/src/Umbraco.Web.UI/web.Template.config b/src/Umbraco.Web.UI/web.Template.config index 3a484944e6..837be91b66 100644 --- a/src/Umbraco.Web.UI/web.Template.config +++ b/src/Umbraco.Web.UI/web.Template.config @@ -117,8 +117,6 @@ - - @@ -291,16 +289,12 @@ - - - - diff --git a/src/Umbraco.Web/Umbraco.Web.csproj b/src/Umbraco.Web/Umbraco.Web.csproj index afa4790262..4327a96baa 100644 --- a/src/Umbraco.Web/Umbraco.Web.csproj +++ b/src/Umbraco.Web/Umbraco.Web.csproj @@ -109,10 +109,6 @@ ..\packages\ClientDependency.1.9.2\lib\net45\ClientDependency.Core.dll True - - ..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll - True - ..\packages\dotless.1.5.2\lib\dotless.Core.dll @@ -1146,12 +1142,6 @@ - - ASPXCodeBehind - - - ASPXCodeBehind - ASPXCodeBehind @@ -1358,14 +1348,6 @@ publish.aspx - - - - - - - - diff --git a/src/Umbraco.Web/packages.config b/src/Umbraco.Web/packages.config index daef6ee7fd..fb32b8d6a8 100644 --- a/src/Umbraco.Web/packages.config +++ b/src/Umbraco.Web/packages.config @@ -29,5 +29,4 @@ - \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/Blogger.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/Blogger.cs deleted file mode 100644 index 280be0f5b9..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/Blogger.cs +++ /dev/null @@ -1,161 +0,0 @@ - -using CookComputing.XmlRpc; - -namespace CookComputing.Blogger -{ - /// - /// Struct representing a blog category - /// - public struct Category - { - public string categoryid; - public string title; - public string description; - public string htmlUrl; - public string rssUrl; - } - - /// - /// Struct representing a blog post - /// - public struct Post - { - public System.DateTime dateCreated; - [XmlRpcMember( - Description = "Depending on server may be either string or integer. " - + "Use Convert.ToInt32(userid) to treat as integer or " - + "Convert.ToString(userid) to treat as string")] - - //Livejournal sometimes drops these - [XmlRpcMissingMapping(MappingAction.Ignore)] - public object userid; - [XmlRpcMissingMapping(MappingAction.Ignore)] - public string postid; - public string content; - } - - /// - /// Struct containing user information - /// - public struct UserInfo - { - public string url; - public string email; - public string nickname; - public string lastname; - public string firstname; - } - - /// - /// Struct containing Blog information - /// - public struct BlogInfo - { - public string blogid; - public string url; - public string blogName; - } - - public interface IBlogger - { - [XmlRpcMethod("blogger.deletePost", - Description = "Deletes a post.")] - [return: XmlRpcReturnValue(Description = "Always returns true.")] - bool deletePost( - string appKey, - string postid, - string username, - string password, - [XmlRpcParameter( - Description = "Where applicable, this specifies whether the blog " - + "should be republished after the post has been deleted.")] - bool publish); - - [XmlRpcMethod("blogger.editPost", - Description = "Edits a given post. Optionally, will publish the " - + "blog after making the edit.")] - [return: XmlRpcReturnValue(Description = "Always returns true.")] - object editPost( - string appKey, - string postid, - string username, - string password, - string content, - bool publish); - - [XmlRpcMethod("blogger.getCategories", - Description = "Returns a list of the categories that you can use " - + "to log against a post.")] - Category[] getCategories( - string blogid, - string username, - string password); - - [XmlRpcMethod("blogger.getPost", - Description = "Returns a single post.")] - Post getPost( - string appKey, - string postid, - string username, - string password); - - [XmlRpcMethod("blogger.getRecentPosts", - Description = "Returns a list of the most recent posts in the system.")] - Post[] getRecentPosts( - string appKey, - string blogid, - string username, - string password, - int numberOfPosts); - - [XmlRpcMethod("blogger.getTemplate", - Description = "Returns the main or archive index template of " - + "a given blog.")] - string getTemplate( - string appKey, - string blogid, - string username, - string password, - string templateType); - - [XmlRpcMethod("blogger.getUserInfo", - Description = "Authenticates a user and returns basic user info " - + "(name, email, userid, etc.).")] - UserInfo getUserInfo( - string appKey, - string username, - string password); - - [XmlRpcMethod("blogger.getUsersBlogs", - Description = "Returns information on all the blogs a given user " - + "is a member.")] - BlogInfo[] getUsersBlogs( - string appKey, - string username, - string password); - - [XmlRpcMethod("blogger.newPost", - Description = "Makes a new post to a designated blog. Optionally, " - + "will publish the blog after making the post.")] - [return: XmlRpcReturnValue(Description = "Id of new post")] - string newPost( - string appKey, - string blogid, - string username, - string password, - string content, - bool publish); - - [XmlRpcMethod("blogger.setTemplate", - Description = "Edits the main or archive index template of a given blog.")] - bool setTemplate( - string appKey, - string blogid, - string username, - string password, - string template, - string templateType); - } -} - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/DocumentDateComparer.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/DocumentDateComparer.cs deleted file mode 100644 index f5951b9ffb..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/DocumentDateComparer.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using umbraco.cms.businesslogic; -using umbraco.cms.businesslogic.web; -namespace umbraco.presentation.channels -{ - class DocumentDateComparer : IComparer - { - - int IComparer.Compare(Object x, Object y) - { - - if (((Document)x).CreateDateTime > ((Document)y).CreateDateTime) - { - return -1; - } - else - { - return 0; - } - - } - - } - - - class DocumentSortOrderComparer : IComparer - { - - int IComparer.Compare(Object x, Object y) - { - - if (((CMSNode)x).sortOrder > ((CMSNode)y).sortOrder) - { - return -1; - } - else - { - return 0; - } - - } - - } - - -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/MetaWeblog.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/MetaWeblog.cs deleted file mode 100644 index 74b7d5d724..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/MetaWeblog.cs +++ /dev/null @@ -1,139 +0,0 @@ - -using System; -using CookComputing.XmlRpc; - -namespace CookComputing.MetaWeblog -{ - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct Enclosure - { - public int length; - public string type; - public string url; - } - - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct Source - { - public string name; - public string url; - } - - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct Post - { - [XmlRpcMissingMapping(MappingAction.Error)] - [XmlRpcMember(Description = "Required when posting.")] - public DateTime dateCreated; - [XmlRpcMissingMapping(MappingAction.Error)] - [XmlRpcMember(Description = "Required when posting.")] - public string description; - [XmlRpcMissingMapping(MappingAction.Error)] - [XmlRpcMember(Description = "Required when posting.")] - public string title; - - public string[] categories; - public Enclosure enclosure; - public string link; - public string permalink; - [XmlRpcMember( - Description = "Not required when posting. Depending on server may " - + "be either string or integer. " - + "Use Convert.ToInt32(postid) to treat as integer or " - + "Convert.ToString(postid) to treat as string")] - public object postid; - public Source source; - public string userid; - - public object mt_allow_comments; - public object mt_allow_pings; - public object mt_convert_breaks; - public string mt_text_more; - public string mt_excerpt; - } - - public struct CategoryInfo - { - public string description; - public string htmlUrl; - public string rssUrl; - public string title; - public string categoryid; - } - - public struct Category - { - public string categoryId; - public string categoryName; - } - - public struct FileData - { - public byte[] bits; - public string name; - public string type; - } - - public struct UrlData - { - public string url; - } - - public struct MediaObjectInfo - { - public string url; - } - - public interface IMetaWeblog - { - [XmlRpcMethod("metaWeblog.editPost", - Description = "Updates and existing post to a designated blog " - + "using the metaWeblog API. Returns true if completed.")] - object editPost( - string postid, - string username, - string password, - Post post, - bool publish); - - [XmlRpcMethod("metaWeblog.getCategories", - Description = "Retrieves a list of valid categories for a post " - + "using the metaWeblog API. Returns the metaWeblog categories " - + "struct collection.")] - CategoryInfo[] getCategories( - string blogid, - string username, - string password); - - [XmlRpcMethod("metaWeblog.getPost", - Description = "Retrieves an existing post using the metaWeblog " - + "API. Returns the metaWeblog struct.")] - Post getPost( - string postid, - string username, - string password); - - [XmlRpcMethod("metaWeblog.getRecentPosts", - Description = "Retrieves a list of the most recent existing post " - + "using the metaWeblog API. Returns the metaWeblog struct collection.")] - Post[] getRecentPosts( - string blogid, - string username, - string password, - int numberOfPosts); - - [XmlRpcMethod("metaWeblog.newPost", - Description = "Makes a new post to a designated blog using the " - + "metaWeblog API. Returns postid as a string.")] - string newPost( - string blogid, - string username, - string password, - Post post, - bool publish); - - - } -} - - diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs deleted file mode 100644 index b4fa6ed573..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/UmbracoMetaWeblogAPI.cs +++ /dev/null @@ -1,568 +0,0 @@ -using System; -using System.Collections; -using System.Drawing; -using System.IO; -using System.Web; -using CookComputing.Blogger; -using CookComputing.MetaWeblog; -using CookComputing.XmlRpc; -using Umbraco.Core.Configuration; -using Umbraco.Core.IO; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic; -using umbraco.cms.businesslogic.datatype; -using umbraco.cms.businesslogic.media; -using umbraco.cms.businesslogic.property; -using umbraco.cms.businesslogic.propertytype; -using umbraco.cms.businesslogic.web; -using Umbraco.Core.Logging; -using Umbraco.Core.Security; -using umbraco.presentation.channels.businesslogic; -using Post = CookComputing.MetaWeblog.Post; - -using System.Collections.Generic; -using System.Web.Security; -using Umbraco.Core.IO; -using Umbraco.Core; - -namespace umbraco.presentation.channels -{ - public abstract class UmbracoMetaWeblogAPI : XmlRpcService, IMetaWeblog - { - internal readonly MediaFileSystem _fs; - - protected UmbracoMetaWeblogAPI() - { - _fs = FileSystemProviderManager.Current.GetFileSystemProvider(); - } - - [XmlRpcMethod("blogger.deletePost", - Description = "Deletes a post.")] - [return: XmlRpcReturnValue(Description = "Always returns true.")] - public bool deletePost( - string appKey, - string postid, - string username, - string password, - [XmlRpcParameter( - Description = "Where applicable, this specifies whether the blog " - + "should be republished after the post has been deleted.")] bool publish) - { - if (ValidateUser(username, password)) - { - Channel userChannel = new Channel(username); - new Document(int.Parse(postid)) - .delete(); - return true; - } - return false; - } - - public object editPost( - string postid, - string username, - string password, - Post post, - bool publish) - { - if (ValidateUser(username, password)) - { - Channel userChannel = new Channel(username); - Document doc = new Document(Convert.ToInt32(postid)); - - - doc.Text = HttpContext.Current.Server.HtmlDecode(post.title); - - // Excerpt - if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "") - doc.getProperty(userChannel.FieldExcerptAlias).Value = RemoveLeftUrl(post.mt_excerpt); - - - if (UmbracoConfig.For.UmbracoSettings().Content.TidyEditorContent) - doc.getProperty(userChannel.FieldDescriptionAlias).Value = library.Tidy(RemoveLeftUrl(post.description), false); - else - doc.getProperty(userChannel.FieldDescriptionAlias).Value = RemoveLeftUrl(post.description); - - UpdateCategories(doc, post, userChannel); - - - if (publish) - { - doc.SaveAndPublish(new User(username)); - } - return true; - } - else - { - return false; - } - } - - private static void UpdateCategories(Document doc, Post post, Channel userChannel) - { - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "") - { - ContentType blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias); - PropertyType categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias); - - String[] categories = post.categories; - string categoryValue = ""; - interfaces.IUseTags tags = UseTags(categoryType); - if (tags != null) - { - tags.RemoveTagsFromNode(doc.Id); - for (int i = 0; i < categories.Length; i++) - { - tags.AddTagToNode(doc.Id, categories[i]); - } - //If the IUseTags provider manually set the property value to something on the IData interface then we should persist this - //code commented as for some reason, even though the IUseTags control is setting IData.Value it is null here - //could be a cache issue, or maybe it's a different instance of the IData or something, rather odd - //doc.getProperty(userChannel.FieldCategoriesAlias).Value = categoryType.DataTypeDefinition.DataType.Data.Value; - - //Instead, set the document property to CSV of the tags - this WILL break custom editors for tags which don't adhere to the - //pseudo standard that the .Value of the property contains CSV tags. - doc.getProperty(userChannel.FieldCategoriesAlias).Value = string.Join(",", categories); - } - else - { - for (int i = 0; i < categories.Length; i++) - { - PreValue pv = new PreValue(categoryType.DataTypeDefinition.Id, categories[i]); - categoryValue += pv.Id + ","; - } - if (categoryValue.Length > 0) - categoryValue = categoryValue.Substring(0, categoryValue.Length - 1); - - doc.getProperty(userChannel.FieldCategoriesAlias).Value = categoryValue; - } - } - } - - public CategoryInfo[] getCategories( - string blogid, - string username, - string password) - { - if (ValidateUser(username, password)) - { - Channel userChannel = new Channel(username); - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "") - { - // Find the propertytype via the document type - ContentType blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias); - PropertyType categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias); - - // check if the datatype uses tags or prevalues - CategoryInfo[] returnedCategories = null; - interfaces.IUseTags tags = UseTags(categoryType); - if (tags != null) - { - List alltags = tags.GetAllTags(); - if (alltags != null) - { - returnedCategories = new CategoryInfo[alltags.Count]; - int counter = 0; - foreach (interfaces.ITag t in alltags) - { - CategoryInfo ci = new CategoryInfo(); - ci.title = t.TagCaption; - ci.categoryid = t.Id.ToString(); - ci.description = ""; - ci.rssUrl = ""; - ci.htmlUrl = ""; - returnedCategories[counter] = ci; - counter++; - } - } - else - { - returnedCategories = new CategoryInfo[0]; - } - } - else - { - SortedList categories = PreValues.GetPreValues(categoryType.DataTypeDefinition.Id); - returnedCategories = new CategoryInfo[categories.Count]; - IDictionaryEnumerator ide = categories.GetEnumerator(); - int counter = 0; - while (ide.MoveNext()) - { - PreValue category = (PreValue)ide.Value; - CategoryInfo ci = new CategoryInfo(); - ci.title = category.Value; - ci.categoryid = category.Id.ToString(); - ci.description = ""; - ci.rssUrl = ""; - ci.htmlUrl = ""; - returnedCategories[counter] = ci; - counter++; - } - } - - return returnedCategories; - } - } - - throw new ArgumentException("Categories doesn't work for this channel, they might not have been activated. Contact your umbraco administrator."); - } - - public static interfaces.IUseTags UseTags(PropertyType categoryType) - { - if (typeof(interfaces.IUseTags).IsAssignableFrom(categoryType.DataTypeDefinition.DataType.DataEditor.GetType())) - { - interfaces.IUseTags tags = (interfaces.IUseTags)categoryType.DataTypeDefinition.DataType.DataEditor as interfaces.IUseTags; - return tags; - } - return null; - } - - public Post getPost( - string postid, - string username, - string password) - { - if (ValidateUser(username, password)) - { - Channel userChannel = new Channel(username); - Document d = new Document(int.Parse(postid)); - Post p = new Post(); - p.title = d.Text; - p.description = d.getProperty(userChannel.FieldDescriptionAlias).Value.ToString(); - - // Excerpt - if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "") - p.mt_excerpt = d.getProperty(userChannel.FieldExcerptAlias).Value.ToString(); - - // Categories - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "" && - d.getProperty(userChannel.FieldCategoriesAlias) != null && - d.getProperty(userChannel.FieldCategoriesAlias).Value != null && - d.getProperty(userChannel.FieldCategoriesAlias).Value.ToString() != "") - { - String categories = d.getProperty(userChannel.FieldCategoriesAlias).Value.ToString(); - char[] splitter = { ',' }; - String[] categoryIds = categories.Split(splitter); - p.categories = categoryIds; - } - - p.postid = postid; - p.permalink = library.NiceUrl(d.Id); - p.dateCreated = d.CreateDateTime; - p.link = p.permalink; - return p; - } - else - throw new ArgumentException(string.Format("Error retriving post with id: '{0}'", postid)); - } - - public Post[] getRecentPosts( - string blogid, - string username, - string password, - int numberOfPosts) - { - if (ValidateUser(username, password)) - { - ArrayList blogPosts = new ArrayList(); - ArrayList blogPostsObjects = new ArrayList(); - - User u = new User(username); - Channel userChannel = new Channel(u.Id); - - - Document rootDoc; - if (userChannel.StartNode > 0) - rootDoc = new Document(userChannel.StartNode); - else - { - if (u.StartNodeId == -1) - { - rootDoc = Document.GetRootDocuments()[0]; - } - else - { - rootDoc = new Document(u.StartNodeId); - } - } - - //store children array here because iterating over an Array object is very inneficient. - var c = rootDoc.Children; - foreach (Document d in c) - { - int count = 0; - blogPosts.AddRange( - findBlogPosts(userChannel, d, u.Name, ref count, numberOfPosts, userChannel.FullTree)); - } - - blogPosts.Sort(new DocumentSortOrderComparer()); - - foreach (Object o in blogPosts) - { - Document d = (Document)o; - Post p = new Post(); - p.dateCreated = d.CreateDateTime; - p.userid = username; - p.title = d.Text; - p.permalink = library.NiceUrl(d.Id); - p.description = d.getProperty(userChannel.FieldDescriptionAlias).Value.ToString(); - p.link = library.NiceUrl(d.Id); - p.postid = d.Id.ToString(); - - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "" && - d.getProperty(userChannel.FieldCategoriesAlias) != null && - d.getProperty(userChannel.FieldCategoriesAlias).Value != null && - d.getProperty(userChannel.FieldCategoriesAlias).Value.ToString() != "") - { - String categories = d.getProperty(userChannel.FieldCategoriesAlias).Value.ToString(); - char[] splitter = { ',' }; - String[] categoryIds = categories.Split(splitter); - p.categories = categoryIds; - } - - // Excerpt - if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "") - p.mt_excerpt = d.getProperty(userChannel.FieldExcerptAlias).Value.ToString(); - - - blogPostsObjects.Add(p); - } - - - return (Post[])blogPostsObjects.ToArray(typeof(Post)); - } - else - { - return null; - } - } - - protected ArrayList findBlogPosts(Channel userChannel, Document d, String userName, ref int count, int max, - bool fullTree) - { - ArrayList list = new ArrayList(); - - ContentType ct = d.ContentType; - - if (ct.Alias.Equals(userChannel.DocumentTypeAlias) & - (count < max)) - { - list.Add(d); - count = count + 1; - } - - if (d.Children != null && d.Children.Length > 0 && fullTree) - { - //store children array here because iterating over an Array object is very inneficient. - var c = d.Children; - foreach (Document child in c) - { - if (count < max) - { - list.AddRange(findBlogPosts(userChannel, child, userName, ref count, max, true)); - } - } - } - return list; - } - - public string newPost( - string blogid, - string username, - string password, - Post post, - bool publish) - { - if (ValidateUser(username, password)) - { - Channel userChannel = new Channel(username); - User u = new User(username); - Document doc = - Document.MakeNew(HttpContext.Current.Server.HtmlDecode(post.title), - DocumentType.GetByAlias(userChannel.DocumentTypeAlias), u, - userChannel.StartNode); - - - // Excerpt - if (userChannel.FieldExcerptAlias != null && userChannel.FieldExcerptAlias != "") - doc.getProperty(userChannel.FieldExcerptAlias).Value = RemoveLeftUrl(post.mt_excerpt); - - - // Description - if (UmbracoConfig.For.UmbracoSettings().Content.TidyEditorContent) - doc.getProperty(userChannel.FieldDescriptionAlias).Value = library.Tidy(RemoveLeftUrl(post.description), false); - else - doc.getProperty(userChannel.FieldDescriptionAlias).Value = RemoveLeftUrl(post.description); - - // Categories - UpdateCategories(doc, post, userChannel); - - // check release date - if (post.dateCreated.Year > 0001) - { - publish = false; - doc.ReleaseDate = post.dateCreated; - } - - if (publish) - { - doc.SaveAndPublish(new User(username)); - } - return doc.Id.ToString(); - } - else - throw new ArgumentException("Error creating post"); - } - - protected MediaObjectInfo newMediaObjectLogicForWord( - string blogid, - string username, - string password, - FileData file) - { - UrlData ud = newMediaObjectLogic(blogid, username, password, file); - MediaObjectInfo moi = new MediaObjectInfo(); - moi.url = ud.url; - return moi; - } - protected UrlData newMediaObjectLogic( - string blogid, - string username, - string password, - FileData file) - { - if (ValidateUser(username, password)) - { - User u = new User(username); - Channel userChannel = new Channel(username); - UrlData fileUrl = new UrlData(); - if (userChannel.ImageSupport) - { - Media rootNode; - if (userChannel.MediaFolder > 0) - rootNode = new Media(userChannel.MediaFolder); - else - rootNode = new Media(u.StartMediaId); - - // Create new media - Media m = Media.MakeNew(file.name, MediaType.GetByAlias(userChannel.MediaTypeAlias), u, rootNode.Id); - - Property fileObject = m.getProperty(userChannel.MediaTypeFileProperty); - - var filename = file.name.Replace("/", "_"); - var relativeFilePath = UmbracoMediaFactory.GetRelativePath(fileObject.Id, filename); - - fileObject.Value = _fs.GetUrl(relativeFilePath); - fileUrl.url = fileObject.Value.ToString(); - - if (!fileUrl.url.StartsWith("http")) - { - var protocol = GlobalSettings.UseSSL ? "https" : "http"; - fileUrl.url = protocol + "://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + fileUrl.url; - } - - _fs.AddFile(relativeFilePath, new MemoryStream(file.bits)); - - // Try updating standard file values - try - { - string orgExt = ""; - // Size - if (m.getProperty(Constants.Conventions.Media.Bytes) != null) - m.getProperty(Constants.Conventions.Media.Bytes).Value = file.bits.Length; - // Extension - if (m.getProperty(Constants.Conventions.Media.Extension) != null) - { - orgExt = - ((string) - file.name.Substring(file.name.LastIndexOf(".") + 1, - file.name.Length - file.name.LastIndexOf(".") - 1)); - m.getProperty(Constants.Conventions.Media.Extension).Value = orgExt.ToLower(); - } - // Width and Height - // Check if image and then get sizes, make thumb and update database - if (m.getProperty(Constants.Conventions.Media.Width) != null && m.getProperty(Constants.Conventions.Media.Height) != null && - ",jpeg,jpg,gif,bmp,png,tiff,tif,".IndexOf("," + orgExt.ToLower() + ",") > 0) - { - int fileWidth; - int fileHeight; - - using (var stream = _fs.OpenFile(relativeFilePath)) - { - Image image = Image.FromStream(stream); - fileWidth = image.Width; - fileHeight = image.Height; - stream.Close(); - try - { - m.getProperty(Constants.Conventions.Media.Width).Value = fileWidth.ToString(); - m.getProperty(Constants.Conventions.Media.Height).Value = fileHeight.ToString(); - } - catch (Exception ex) - { - LogHelper.Error("An error occurred reading the media stream", ex); - } - } - - - } - } - catch (Exception ex) - { - LogHelper.Error("An error occurred in newMediaObjectLogic", ex); - } - - return fileUrl; - } - else - throw new ArgumentException( - "Image Support is turned off in this channel. Modify channel settings in umbraco to enable image support."); - } - return new UrlData(); - } - - private static bool ValidateUser(string username, string password) - { - var provider = MembershipProviderExtensions.GetUsersMembershipProvider(); - - return provider.ValidateUser(username, password); - } - - [XmlRpcMethod("blogger.getUsersBlogs", - Description = "Returns information on all the blogs a given user " - + "is a member.")] - public BlogInfo[] getUsersBlogs( - string appKey, - string username, - string password) - { - if (ValidateUser(username, password)) - { - BlogInfo[] blogs = new BlogInfo[1]; - User u = new User(username); - Channel userChannel = new Channel(u.Id); - Document rootDoc; - if (userChannel.StartNode > 0) - rootDoc = new Document(userChannel.StartNode); - else - rootDoc = new Document(u.StartNodeId); - - BlogInfo bInfo = new BlogInfo(); - bInfo.blogName = userChannel.Name; - bInfo.blogid = rootDoc.Id.ToString(); - bInfo.url = library.NiceUrlWithDomain(rootDoc.Id, true); - blogs[0] = bInfo; - - return blogs; - } - - throw new ArgumentException(string.Format("No data found for user with username: '{0}'", username)); - } - - private static string RemoveLeftUrl(string text) - { - return - text.Replace(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), ""); - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/api.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/api.cs deleted file mode 100644 index ace78f6803..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/api.cs +++ /dev/null @@ -1,223 +0,0 @@ -using System; -using System.Collections; -using CookComputing.MetaWeblog; -using CookComputing.XmlRpc; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic; -using umbraco.cms.businesslogic.datatype; -using umbraco.cms.businesslogic.propertytype; -using umbraco.cms.businesslogic.web; -using umbraco.presentation.channels.businesslogic; - -namespace umbraco.presentation.channels -{ - /// - /// the umbraco channels API is xml-rpc webservice based on the metaweblog and blogger APIs - /// for editing umbraco data froom external clients - /// - [XmlRpcService( - Name = "umbraco metablog api", - Description = "For editing umbraco data from external clients", - AutoDocumentation = true)] - public class api : UmbracoMetaWeblogAPI, IRemixWeblogApi - { - /// - /// Initializes a new instance of the class. - /// - public api() - { - } - - - /// - /// Makes a new file to a designated blog using the metaWeblog API - /// - /// The blogid. - /// The username. - /// The password. - /// The file. - /// Returns url as a string of a struct. - [XmlRpcMethod("metaWeblog.newMediaObject", - Description = "Makes a new file to a designated blog using the " - + "metaWeblog API. Returns url as a string of a struct.")] - public UrlData newMediaObject( - string blogid, - string username, - string password, - FileData file) - { - return newMediaObjectLogic(blogid, username, password, file); - } - - #region IRemixWeblogApi Members - - /// - /// Gets a summary of all the pages from the blog with the spefied blogId. - /// - /// The blogid. - /// The username. - /// The password. - /// - public wpPageSummary[] getPageList(string blogid, string username, string password) - { - if (User.validateCredentials(username, password, false)) - { - ArrayList blogPosts = new ArrayList(); - ArrayList blogPostsObjects = new ArrayList(); - - User u = new User(username); - Channel userChannel = new Channel(u.Id); - - - Document rootDoc; - if (userChannel.StartNode > 0) - rootDoc = new Document(userChannel.StartNode); - else - rootDoc = new Document(u.StartNodeId); - - //store children array here because iterating over an Array object is very inneficient. - var c = rootDoc.Children; - foreach (Document d in c) - { - int count = 0; - blogPosts.AddRange( - findBlogPosts(userChannel, d, u.Name, ref count, 999, userChannel.FullTree)); - } - - blogPosts.Sort(new DocumentSortOrderComparer()); - - foreach (Object o in blogPosts) - { - Document d = (Document)o; - wpPageSummary p = new wpPageSummary(); - p.dateCreated = d.CreateDateTime; - p.page_title = d.Text; - p.page_id = d.Id; - p.page_parent_id = d.ParentId; - - blogPostsObjects.Add(p); - } - - - return (wpPageSummary[])blogPostsObjects.ToArray(typeof(wpPageSummary)); - } - else - { - return null; - } - } - - /// - /// Gets a specified number of pages from the blog with the spefied blogId - /// - /// The blogid. - /// The username. - /// The password. - /// The number of pages. - /// - public wpPage[] getPages(string blogid, string username, string password, int numberOfItems) - { - if (User.validateCredentials(username, password, false)) - { - ArrayList blogPosts = new ArrayList(); - ArrayList blogPostsObjects = new ArrayList(); - - User u = new User(username); - Channel userChannel = new Channel(u.Id); - - - Document rootDoc; - if (userChannel.StartNode > 0) - rootDoc = new Document(userChannel.StartNode); - else - rootDoc = new Document(u.StartNodeId); - - //store children array here because iterating over an Array object is very inneficient. - var c = rootDoc.Children; - foreach (Document d in c) - { - int count = 0; - blogPosts.AddRange( - findBlogPosts(userChannel, d, u.Name, ref count, numberOfItems, userChannel.FullTree)); - } - - blogPosts.Sort(new DocumentSortOrderComparer()); - - foreach (Object o in blogPosts) - { - Document d = (Document)o; - wpPage p = new wpPage(); - p.dateCreated = d.CreateDateTime; - p.title = d.Text; - p.page_id = d.Id; - p.wp_page_parent_id = d.ParentId; - p.wp_page_parent_title = d.Parent.Text; - p.permalink = library.NiceUrl(d.Id); - p.description = d.getProperty(userChannel.FieldDescriptionAlias).Value.ToString(); - p.link = library.NiceUrl(d.Id); - - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "" && - d.getProperty(userChannel.FieldCategoriesAlias) != null && - ((string)d.getProperty(userChannel.FieldCategoriesAlias).Value) != "") - { - String categories = d.getProperty(userChannel.FieldCategoriesAlias).Value.ToString(); - char[] splitter = { ',' }; - String[] categoryIds = categories.Split(splitter); - p.categories = categoryIds; - } - - - blogPostsObjects.Add(p); - } - - - return (wpPage[])blogPostsObjects.ToArray(typeof(wpPage)); - } - else - { - return null; - } - } - - /// - /// Creates a new blog category / tag. - /// - /// The blogid. - /// The username. - /// The password. - /// The category. - /// - public string newCategory( - string blogid, - string username, - string password, - wpCategory category) - { - if (User.validateCredentials(username, password, false)) - { - Channel userChannel = new Channel(username); - if (userChannel.FieldCategoriesAlias != null && userChannel.FieldCategoriesAlias != "") - { - // Find the propertytype via the document type - ContentType blogPostType = ContentType.GetByAlias(userChannel.DocumentTypeAlias); - PropertyType categoryType = blogPostType.getPropertyType(userChannel.FieldCategoriesAlias); - interfaces.IUseTags tags = UseTags(categoryType); - if (tags != null) - { - tags.AddTag(category.name); - } - else - { - PreValue pv = new PreValue(); - pv.DataTypeId = categoryType.DataTypeDefinition.Id; - pv.Value = category.name; - pv.Save(); - } - } - } - return ""; - } - - #endregion - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/config.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/config.cs deleted file mode 100644 index 3cb25cb765..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/config.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System; -using System.IO; -using System.Web; -using System.Xml; -using umbraco.BusinessLogic; -using Umbraco.Core.IO; - -namespace umbraco.presentation.channels.businesslogic -{ - public class config - { - private static XmlDocument _metablogConfigFile; - - public static XmlDocument MetaBlogConfigFile - { - get - { - if (_metablogConfigFile == null) - { - _metablogConfigFile = new XmlDocument(); - _metablogConfigFile.Load(IOHelper.MapPath(SystemFiles.MetablogConfig)); - } - - return _metablogConfigFile; - } - } - } - - public class Channel - { - public Channel(string username) - { - User u = new User(username); - initialize(u.Id); - } - - public Channel(int UserId) - { - initialize(UserId); - } - - private void initialize(int UserId) - { - XmlDocument configFile = config.MetaBlogConfigFile; - XmlNode channelXml = configFile.SelectSingleNode(string.Format("//channel [user = '{0}']", UserId)); - if (channelXml != null) - { - Id = UserId; - User = new User(UserId); - Name = channelXml.SelectSingleNode("./name").FirstChild.Value; - StartNode = int.Parse(channelXml.SelectSingleNode("./startNode").FirstChild.Value); - FullTree = bool.Parse(channelXml.SelectSingleNode("./fullTree").FirstChild.Value); - DocumentTypeAlias = channelXml.SelectSingleNode("./documentTypeAlias").FirstChild.Value; - if (channelXml.SelectSingleNode("./fields/categories").FirstChild != null) - FieldCategoriesAlias = channelXml.SelectSingleNode("./fields/categories").FirstChild.Value; - if (channelXml.SelectSingleNode("./fields/description").FirstChild != null) - FieldDescriptionAlias = channelXml.SelectSingleNode("./fields/description").FirstChild.Value; - if (channelXml.SelectSingleNode("./fields/excerpt") != null && channelXml.SelectSingleNode("./fields/excerpt").FirstChild != null) - FieldExcerptAlias = channelXml.SelectSingleNode("./fields/excerpt").FirstChild.Value; - - XmlNode mediaSupport = channelXml.SelectSingleNode("./mediaObjectSupport"); - ImageSupport = bool.Parse(mediaSupport.Attributes.GetNamedItem("enabled").Value); - MediaFolder = int.Parse(mediaSupport.Attributes.GetNamedItem("folderId").Value); - MediaTypeAlias = mediaSupport.Attributes.GetNamedItem("mediaTypeAlias").Value; - MediaTypeFileProperty = mediaSupport.Attributes.GetNamedItem("mediaTypeFileProperty").Value; - } - else - throw new ArgumentException(string.Format("No channel found for user with id: '{0}'", UserId)); - } - - public Channel() - { - } - - public void Save() - { - // update node - XmlDocument configFile = config.MetaBlogConfigFile; - XmlNode channelXml = null; - if (User != null && User.Id > -1) - channelXml = configFile.SelectSingleNode(string.Format("//channel [user = '{0}']", this.User.Id)); - if (channelXml != null) - configFile.DocumentElement.RemoveChild(channelXml); - - // add new node - XmlElement newChannelxml = configFile.CreateElement("channel"); - newChannelxml.AppendChild( - xmlHelper.addTextNode(configFile, "name", Name)); - newChannelxml.AppendChild( - xmlHelper.addTextNode(configFile, "user", User.Id.ToString())); - newChannelxml.AppendChild( - xmlHelper.addTextNode(configFile, "startNode", StartNode.ToString())); - newChannelxml.AppendChild( - xmlHelper.addTextNode(configFile, "fullTree", FullTree.ToString())); - newChannelxml.AppendChild( - xmlHelper.addTextNode(configFile, "documentTypeAlias", DocumentTypeAlias)); - - // fields - XmlElement fieldsxml = configFile.CreateElement("fields"); - fieldsxml.AppendChild( - xmlHelper.addTextNode(configFile, "categories", FieldCategoriesAlias)); - fieldsxml.AppendChild( - xmlHelper.addTextNode(configFile, "description", FieldDescriptionAlias)); - fieldsxml.AppendChild( - xmlHelper.addTextNode(configFile, "excerpt", FieldExcerptAlias)); - newChannelxml.AppendChild(fieldsxml); - - - // media - XmlElement media = configFile.CreateElement("mediaObjectSupport"); - media.Attributes.Append(xmlHelper.addAttribute(configFile, "enabled", ImageSupport.ToString())); - media.Attributes.Append(xmlHelper.addAttribute(configFile, "folderId", MediaFolder.ToString())); - media.Attributes.Append(xmlHelper.addAttribute(configFile, "mediaTypeAlias", MediaTypeAlias)); - media.Attributes.Append(xmlHelper.addAttribute(configFile, "mediaTypeFileProperty", MediaTypeFileProperty)); - newChannelxml.AppendChild(media); - configFile.DocumentElement.AppendChild(newChannelxml); - - configFile.Save( IOHelper.MapPath( SystemFiles.MetablogConfig )); - - - } - - private string _fieldExcerptAlias; - - public string FieldExcerptAlias - { - get { return _fieldExcerptAlias; } - set { _fieldExcerptAlias = value; } - } - - - private string _mediaTypeFileProperty; - - public string MediaTypeFileProperty - { - get { return _mediaTypeFileProperty; } - set { _mediaTypeFileProperty = value; } - } - - - private string _mediaTypeAlias; - - public string MediaTypeAlias - { - get { return _mediaTypeAlias; } - set { _mediaTypeAlias = value; } - } - - - private int _mediaFolder; - - public int MediaFolder - { - get { return _mediaFolder; } - set { _mediaFolder = value; } - } - - - private bool _imageSupport; - - public bool ImageSupport - { - get { return _imageSupport; } - set { _imageSupport = value; } - } - - - private int _startNode; - - public int StartNode - { - get { return _startNode; } - set { _startNode = value; } - } - - - private int _id; - - public int Id - { - get { return _id; } - set { _id = value; } - } - - - private string _fieldCategoriesAlias; - - public string FieldCategoriesAlias - { - get { return _fieldCategoriesAlias; } - set { _fieldCategoriesAlias = value; } - } - - - private string _fieldDescriptionAlias; - - public string FieldDescriptionAlias - { - get { return _fieldDescriptionAlias; } - set { _fieldDescriptionAlias = value; } - } - - - private string _documentTypeAlias; - - public string DocumentTypeAlias - { - get { return _documentTypeAlias; } - set { _documentTypeAlias = value; } - } - - - private bool _fulltree; - - public bool FullTree - { - get { return _fulltree; } - set { _fulltree = value; } - } - - - private User _user; - - public User User - { - get { return _user; } - set { _user = value; } - } - - - private string _name; - - public string Name - { - get { return _name; } - set { _name = value; } - } - } -} \ No newline at end of file diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/remixWeblogApi.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/remixWeblogApi.cs deleted file mode 100644 index 6c9103e669..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/remixWeblogApi.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Data; -using System.Configuration; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; -using CookComputing.MetaWeblog; -using CookComputing.XmlRpc; - -namespace umbraco.presentation.channels -{ - - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct wpPage - { - public DateTime dateCreated; - public int userid; - public int page_id; - public string page_status; - public string description; - public string title; - public string link; - public string permalink; - public string[] categories; - public string excerpt; - public string text_more; - public int mt_allow_comments; - public int mt_allow_pings; - - public string wp_slug; - public string wp_password; - public string wp_author; - public int wp_page_parent_id; - public string wp_page_parent_title; - public int wp_page_order; - public int wp_author_id; - public string wp_author_display_name; - - } - - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct wpPageSummary - { - public int page_id; - public string page_title; - public int page_parent_id; - public DateTime dateCreated; - - } - [XmlRpcMissingMapping(MappingAction.Ignore)] - public struct wpCategory - { - public string name; - public string slug; - public int parent_id; - string description; - } - - - public interface IRemixWeblogApi - { - [XmlRpcMethod("wp.getPageList", - Description = "Retrieves a list of pages as summary from the current channel")] - wpPageSummary[] getPageList( - string blogid, - string username, - string password); - - [XmlRpcMethod("wp.getPages", - Description = "Retrieves a list of pages from the current channel")] - wpPage[] getPages( - string blogid, - string username, - string password, - int numberOfItems); - - [XmlRpcMethod("wp.newCategory", - Description = "Adds a new category")] - string newCategory( - string blogid, - string username, - string password, - wpCategory category); - - } - -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs deleted file mode 100644 index 7686a48738..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/rsd.aspx.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Data; -using System.Configuration; -using System.Collections; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; - -namespace umbraco.presentation.umbraco.channels -{ - [Obsolete("This class is no longer used and will be removed from the codebase in future versions")] - public partial class rsd : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - Response.ContentType = "text/xml"; - } - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs deleted file mode 100644 index 51b7b38335..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wlwmanifest.aspx.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using System.Data; -using System.Configuration; -using System.Collections; -using System.Web; -using System.Web.Security; -using System.Web.UI; -using System.Web.UI.WebControls; -using System.Web.UI.WebControls.WebParts; -using System.Web.UI.HtmlControls; - -namespace umbraco.presentation.channels -{ - [Obsolete("This class is no longer used and will be removed from the codebase in future versions")] - public partial class wlwmanifest : System.Web.UI.Page - { - protected void Page_Load(object sender, EventArgs e) - { - bool useXhtml = false; - if (bool.TryParse(GlobalSettings.EditXhtmlMode, out useXhtml) && !useXhtml) - { - xhtml.Text = "no"; - } - else - { - xhtml.Text = "yes"; - } - } - - /// - /// xhtml control. - /// - /// - /// Auto-generated field. - /// To modify move field declaration from designer file to code-behind file. - /// - protected global::System.Web.UI.WebControls.Literal xhtml; - } -} diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wordApi.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wordApi.cs deleted file mode 100644 index cc9fcf1e64..0000000000 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/channels/wordApi.cs +++ /dev/null @@ -1,32 +0,0 @@ -using CookComputing.MetaWeblog; -using CookComputing.XmlRpc; - -namespace umbraco.presentation.channels -{ - /// - /// Summary description for Test. - /// - [XmlRpcService( - Name = "umbraco metablog test", - Description = "For editing umbraco data from external clients", - AutoDocumentation = true)] - public class wordApi : UmbracoMetaWeblogAPI - { - public wordApi() - { - } - - [XmlRpcMethod("metaWeblog.newMediaObject", - Description = "Makes a new file to a designated blog using the " - + "metaWeblog API. Returns url as a string of a struct.")] - public MediaObjectInfo newMediaObject( - string blogid, - string username, - string password, - FileData file) - { - return newMediaObjectLogicForWord(blogid.ToString(), username, password, file); - } - - } -} \ No newline at end of file