U4-5546 Remove user 'channels', weblog api, and all code / db tables relevant to those
This commit is contained in:
@@ -110,6 +110,8 @@
|
||||
</httpModules>
|
||||
<httpHandlers>
|
||||
<add path="GoogleSpellChecker.ashx" xdt:Transform="Remove" xdt:Locator="Match(path)" />
|
||||
<add path="umbraco/channels.aspx" xdt:Transform="Remove" xdt:Locator="Match(path)" />
|
||||
<add path="umbraco/channels/word.aspx" xdt:Transform="Remove" xdt:Locator="Match(path)" />
|
||||
</httpHandlers>
|
||||
</system.web>
|
||||
|
||||
@@ -324,6 +326,10 @@
|
||||
<handlers>
|
||||
<remove name="SpellChecker" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
<add name="SpellChecker" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
<remove name="Channels" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
<add name="Channels" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
<remove name="Channels_Word" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
<add name="Channels_Word" xdt:Transform="Remove" xdt:Locator="Match(name)" />
|
||||
</handlers>
|
||||
|
||||
<!-- Increase the default upload file size limit -->
|
||||
|
||||
@@ -117,8 +117,6 @@
|
||||
<add verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
|
||||
<add verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
|
||||
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />
|
||||
<add verb="*" path="umbraco/channels.aspx" type="umbraco.presentation.channels.api, umbraco" />
|
||||
<add verb="*" path="umbraco/channels/word.aspx" type="umbraco.presentation.channels.wordApi, umbraco" />
|
||||
<add verb="*" path="DependencyHandler.axd" type="ClientDependency.Core.CompositeFiles.CompositeDependencyHandler, ClientDependency.Core " />
|
||||
</httpHandlers>
|
||||
|
||||
@@ -291,16 +289,12 @@
|
||||
<remove name="ScriptHandlerFactory" />
|
||||
<remove name="ScriptHandlerFactoryAppServices" />
|
||||
<remove name="ScriptResource" />
|
||||
<remove name="Channels" />
|
||||
<remove name="Channels_Word" />
|
||||
<remove name="ClientDependency" />
|
||||
<remove name="MiniProfiler" />
|
||||
|
||||
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<add name="ScriptResource" verb="GET,HEAD" path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
|
||||
<add verb="*" name="Channels" preCondition="integratedMode" path="umbraco/channels.aspx" type="umbraco.presentation.channels.api, umbraco" />
|
||||
<add verb="*" name="Channels_Word" preCondition="integratedMode" path="umbraco/channels/word.aspx" type="umbraco.presentation.channels.wordApi, umbraco" />
|
||||
<add verb="*" name="ClientDependency" preCondition="integratedMode" path="DependencyHandler.axd" type="ClientDependency.Core.CompositeFiles.CompositeDependencyHandler, ClientDependency.Core" />
|
||||
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
|
||||
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
|
||||
|
||||
@@ -109,10 +109,6 @@
|
||||
<HintPath>..\packages\ClientDependency.1.9.2\lib\net45\ClientDependency.Core.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="CookComputing.XmlRpcV2, Version=2.5.0.0, Culture=neutral, PublicKeyToken=a7d6e17aa302004d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="dotless.Core, Version=1.5.2.0, Culture=neutral, PublicKeyToken=96b446c9e63eae34, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\dotless.1.5.2\lib\dotless.Core.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -1146,12 +1142,6 @@
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\MacroCacheContent.cs" />
|
||||
<Compile Include="umbraco.presentation\ScriptingMacroResult.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\wlwmanifest.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\rsd.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dialogs\moveOrCopy.aspx.cs">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
@@ -1358,14 +1348,6 @@
|
||||
<Compile Include="umbraco.presentation\umbraco\actions\publish.aspx.designer.cs">
|
||||
<DependentUpon>publish.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\Blogger.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\config.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\DocumentDateComparer.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\MetaWeblog.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\api.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\remixWeblogApi.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\UmbracoMetaWeblogAPI.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\channels\wordApi.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\controls\ContentControl.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\controls\ContentPicker.cs" />
|
||||
<Compile Include="umbraco.presentation\umbraco\controls\ContentTypeControl.cs" />
|
||||
|
||||
@@ -29,5 +29,4 @@
|
||||
<package id="semver" version="1.1.2" targetFramework="net45" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
|
||||
<package id="System.Threading.Tasks.Dataflow" version="4.7.0" targetFramework="net45" />
|
||||
<package id="xmlrpcnet" version="2.5.0" targetFramework="net45" />
|
||||
</packages>
|
||||
@@ -1,161 +0,0 @@
|
||||
|
||||
using CookComputing.XmlRpc;
|
||||
|
||||
namespace CookComputing.Blogger
|
||||
{
|
||||
/// <summary>
|
||||
/// Struct representing a blog category
|
||||
/// </summary>
|
||||
public struct Category
|
||||
{
|
||||
public string categoryid;
|
||||
public string title;
|
||||
public string description;
|
||||
public string htmlUrl;
|
||||
public string rssUrl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Struct representing a blog post
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Struct containing user information
|
||||
/// </summary>
|
||||
public struct UserInfo
|
||||
{
|
||||
public string url;
|
||||
public string email;
|
||||
public string nickname;
|
||||
public string lastname;
|
||||
public string firstname;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Struct containing Blog information
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<MediaFileSystem>();
|
||||
}
|
||||
|
||||
[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<interfaces.ITag> 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<UmbracoMetaWeblogAPI>("An error occurred reading the media stream", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error<UmbracoMetaWeblogAPI>("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), "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// the umbraco channels API is xml-rpc webservice based on the metaweblog and blogger APIs
|
||||
/// for editing umbraco data froom external clients
|
||||
/// </summary>
|
||||
[XmlRpcService(
|
||||
Name = "umbraco metablog api",
|
||||
Description = "For editing umbraco data from external clients",
|
||||
AutoDocumentation = true)]
|
||||
public class api : UmbracoMetaWeblogAPI, IRemixWeblogApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="api"/> class.
|
||||
/// </summary>
|
||||
public api()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Makes a new file to a designated blog using the metaWeblog API
|
||||
/// </summary>
|
||||
/// <param name="blogid">The blogid.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <param name="file">The file.</param>
|
||||
/// <returns>Returns url as a string of a struct.</returns>
|
||||
[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
|
||||
|
||||
/// <summary>
|
||||
/// Gets a summary of all the pages from the blog with the spefied blogId.
|
||||
/// </summary>
|
||||
/// <param name="blogid">The blogid.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a specified number of pages from the blog with the spefied blogId
|
||||
/// </summary>
|
||||
/// <param name="blogid">The blogid.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <param name="numberOfItems">The number of pages.</param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new blog category / tag.
|
||||
/// </summary>
|
||||
/// <param name="blogid">The blogid.</param>
|
||||
/// <param name="username">The username.</param>
|
||||
/// <param name="password">The password.</param>
|
||||
/// <param name="category">The category.</param>
|
||||
/// <returns></returns>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// xhtml control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Literal xhtml;
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
using CookComputing.MetaWeblog;
|
||||
using CookComputing.XmlRpc;
|
||||
|
||||
namespace umbraco.presentation.channels
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Test.
|
||||
/// </summary>
|
||||
[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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user