Update /base for wiki
This commit is contained in:
@@ -12,10 +12,4 @@
|
||||
<permission method="VerifyFile" allowAll="true" />
|
||||
</ext>
|
||||
|
||||
<ext assembly="NotificationsWeb" type="NotificationsWeb.Library.Rest" alias="Notifications">
|
||||
<permission method="SubscribeToForumTopic" allowAll="true" />
|
||||
<permission method="UnSubscribeFromForumTopic" allowAll="true" />
|
||||
<permission method="SubscribeToForum" allowAll="true" />
|
||||
<permission method="UnSubscribeFromForum" allowAll="true" />
|
||||
</ext>
|
||||
</RestExtensions>
|
||||
@@ -53,11 +53,11 @@ var uPowers = function () {
|
||||
},
|
||||
WikiDelete: function (s_Id) {
|
||||
|
||||
$.get("/base/uWiki/Delete/" + s_Id);
|
||||
$.get("/umbraco/api/wiki/Delete/?wikiId=" + s_Id);
|
||||
},
|
||||
WikiMove: function (s_Id, s_target) {
|
||||
|
||||
$.get("/base/uWiki/Move/" + s_Id + "/" + s_target,
|
||||
$.get("/umbraco/api/wiki/Move/?wikiId=" + s_Id + "&target=" + s_target,
|
||||
function (data) {
|
||||
top.location = jQuery("value", data).text();
|
||||
});
|
||||
|
||||
@@ -8,7 +8,7 @@ function RemoveTagFromProject(projectid,tag){
|
||||
|
||||
function VerifyFile(fileId)
|
||||
{
|
||||
$.post("/base/uWiki/VerifyFile/" + fileId + ".aspx");
|
||||
$.post("/umbraco/api/Wiki/VerifyFile/?fileId=" + fileId);
|
||||
}
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
var uWiki = function() {
|
||||
return {
|
||||
Edit: function(s_baseId, s_baseVersion,readOnlyTitle) {
|
||||
|
||||
|
||||
//fetch content from the server in case someone has changed it
|
||||
$.post("/base/uWiki/GetContentVersion/" + s_baseId + "/" + s_baseVersion + ".aspx",
|
||||
$.post("/umbraco/api/Wiki/GetContentVersion/?id=" + s_baseId + "&guid=" + s_baseVersion,
|
||||
function(data){
|
||||
|
||||
if(_currentContent == ''){
|
||||
@@ -82,7 +82,7 @@ var uWiki = function() {
|
||||
|
||||
},
|
||||
Save: function(s_pageId, s_title, s_body, s_keywords) {
|
||||
$.post("/base/uWiki/Update/" + s_pageId + ".aspx", {body: s_body, title: s_title, keywords: s_keywords},
|
||||
$.post("/umbraco/api/Wiki/Update/", { pageId: s_pageId, body: s_body, title: s_title, keywords: s_keywords },
|
||||
function(data){
|
||||
window.location = jQuery("value", data).text();
|
||||
});
|
||||
@@ -90,7 +90,7 @@ var uWiki = function() {
|
||||
uWiki.Cancel(false);
|
||||
},
|
||||
Create: function(s_parentId, s_title, s_body,s_keywords){
|
||||
$.post("/base/uWiki/Create/" + s_parentId + ".aspx", {body: s_body, title: s_title, keywords: s_keywords},
|
||||
$.post("/umbraco/api/Wiki/Create/", {parentId: s_parentId, body: s_body, title: s_title, keywords: s_keywords},
|
||||
function(data){
|
||||
window.location = jQuery("value", data).text();
|
||||
});
|
||||
@@ -120,7 +120,7 @@ var uWiki = function() {
|
||||
}
|
||||
},
|
||||
PreviewOldVersion: function(s_pageId, s_versionGuid, s_currentVersionGuid){
|
||||
$.post("/base/uWiki/GetContentVersion/" + s_pageId + "/" + s_versionGuid + ".aspx",
|
||||
$.post("/umbraco/api/Wiki/GetContentVersion/?id=" + s_pageId + "&guid=" + s_versionGuid,
|
||||
function(data){
|
||||
//jQuery("#wikiContent").html( diffString(_c, jQuery("node/data [alias = 'bodyText']", data).text()) );
|
||||
jQuery("#wikiContent").html( jQuery("node/data [alias = 'bodyText']", data).text() ).effect('highlight');
|
||||
@@ -128,14 +128,14 @@ var uWiki = function() {
|
||||
);
|
||||
},
|
||||
Rollback: function(s_pageId, s_versionGuid){
|
||||
$.post("/base/uWiki/Rollback/" + s_pageId + "/" + s_versionGuid + ".aspx",
|
||||
$.post("/umbraco/api/Wiki/Rollback/?pageId=" + s_pageId + "&guid=" + s_versionGuid,
|
||||
function(data){
|
||||
window.location = jQuery("value", data).text();
|
||||
});
|
||||
},
|
||||
ClearHelpRequests: function(s_section, s_applicationPage){
|
||||
|
||||
$.get("/base/uWiki/ClearHelpRequests/" + s_section + "/" + s_applicationPage + ".aspx");
|
||||
$.get("/umbraco/api/Wiki/ClearHelpRequests/?section=" + s_section + "&applicationPage=" + s_applicationPage);
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Http;
|
||||
using System.Web.Security;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using Umbraco.Web.WebApi;
|
||||
using uWiki.Businesslogic;
|
||||
using uWiki.Library;
|
||||
|
||||
namespace uWiki.Api
|
||||
{
|
||||
public class WikiController : UmbracoApiController
|
||||
{
|
||||
|
||||
public string FileUpload(string pageVersion, string memberGuid)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string Create(int parentId, string body, string title, string keywords)
|
||||
{
|
||||
var currentMemberId = Members.GetCurrentMember().Id;
|
||||
if (parentId > 0 && currentMemberId > 0)
|
||||
{
|
||||
var isAdmin = (Xslt.IsInGroup("admin") || Xslt.IsInGroup("wiki editor"));
|
||||
var doc = new Document(parentId);
|
||||
var isLocked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1");
|
||||
|
||||
if ((isAdmin || isLocked == false) && doc.ContentType.Alias == "WikiPage")
|
||||
{
|
||||
var wikiPage = WikiPage.Create(parentId, currentMemberId, body, title, keywords);
|
||||
return umbraco.library.NiceUrl(wikiPage.NodeId);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string Update(int pageId, string body, string title, string keywords)
|
||||
{
|
||||
var currentMemberId = Members.GetCurrentMember().Id;
|
||||
var isAdmin = (Xslt.IsInGroup("admin") || Xslt.IsInGroup("wiki editor"));
|
||||
|
||||
if (pageId > 0 && currentMemberId > 0 && body.Trim() != "" && title.Trim() != "")
|
||||
{
|
||||
|
||||
var wikiPage = new WikiPage(pageId);
|
||||
|
||||
if (wikiPage.Exists && (isAdmin || wikiPage.Locked == false))
|
||||
{
|
||||
|
||||
wikiPage.Title = title;
|
||||
wikiPage.Author = currentMemberId;
|
||||
wikiPage.Body = body;
|
||||
wikiPage.Keywords = keywords;
|
||||
wikiPage.Save();
|
||||
|
||||
return umbraco.library.NiceUrl(wikiPage.NodeId);
|
||||
}
|
||||
|
||||
return "not allowed " + isAdmin + " " + wikiPage.Locked + " " + wikiPage.Exists;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string GetContentVersion(int id, string guid = null)
|
||||
{
|
||||
if (guid == null)
|
||||
guid = string.Empty;
|
||||
|
||||
return Xslt.GetXmlNodeFromVersion(id, guid, false);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Move(int wikiId, int target)
|
||||
{
|
||||
var currentMemberId = Members.GetCurrentMember().Id;
|
||||
if (Xslt.IsMemberInGroup("admin", currentMemberId) || Xslt.IsMemberInGroup("wiki editor", currentMemberId))
|
||||
{
|
||||
Document document = new Document(wikiId);
|
||||
Document documentTarget = new Document(target);
|
||||
|
||||
if (documentTarget.ContentType.Alias == "WikiPage")
|
||||
{
|
||||
|
||||
Document o = new Document(document.Parent.Id);
|
||||
|
||||
document.Move(documentTarget.Id);
|
||||
document.Save();
|
||||
|
||||
document.Publish(new umbraco.BusinessLogic.User(0));
|
||||
documentTarget.Publish(new umbraco.BusinessLogic.User(0));
|
||||
o.Publish(new umbraco.BusinessLogic.User(0));
|
||||
|
||||
umbraco.library.UpdateDocumentCache(document.Id);
|
||||
umbraco.library.UpdateDocumentCache(documentTarget.Id);
|
||||
umbraco.library.UpdateDocumentCache(o.Id);
|
||||
|
||||
umbraco.library.RefreshContent();
|
||||
|
||||
return umbraco.library.NiceUrl(document.Id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string Delete(int wikiId)
|
||||
{
|
||||
var currentMemberId = Members.GetCurrentMember().Id;
|
||||
|
||||
if (Xslt.IsMemberInGroup("admin", currentMemberId) || Xslt.IsMemberInGroup("wiki editor", currentMemberId))
|
||||
{
|
||||
var document = new Document(wikiId);
|
||||
|
||||
umbraco.library.UnPublishSingleNode(document.Id);
|
||||
document.delete();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string VerifyFile(int fileId)
|
||||
{
|
||||
if (Xslt.IsMemberInGroup("admin", Members.GetCurrentMember().Id))
|
||||
{
|
||||
var wikiFile = new WikiFile(fileId) { Verified = true };
|
||||
wikiFile.Save();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public string Rollback(int pageId, string guid)
|
||||
{
|
||||
var currentMemberId = Members.GetCurrentMember().Id;
|
||||
var olddoc = new Document(pageId, new Guid(guid));
|
||||
var wikiPage = new WikiPage(pageId);
|
||||
|
||||
if (olddoc != null && wikiPage.Exists && !wikiPage.Locked && currentMemberId > 0 && wikiPage.Version.ToString() != guid)
|
||||
{
|
||||
|
||||
wikiPage.Body = olddoc.getProperty("bodyText").Value.ToString();
|
||||
wikiPage.Title = olddoc.Text;
|
||||
wikiPage.Author = currentMemberId;
|
||||
wikiPage.Save();
|
||||
|
||||
return umbraco.library.NiceUrl(wikiPage.NodeId);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public void ClearHelpRequests(string section, string applicationPage)
|
||||
{
|
||||
Data.SqlHelper.ExecuteNonQuery(
|
||||
"Delete from wikiHelpRequest where section = @section and applicationPage = @applicationPage",
|
||||
Data.SqlHelper.CreateParameter("@section", section),
|
||||
Data.SqlHelper.CreateParameter("@applicationPage", applicationPage));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,170 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.web;
|
||||
using System.Xml.XPath;
|
||||
using System.Xml;
|
||||
using uWiki.Businesslogic;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace uWiki.Library {
|
||||
public class Rest {
|
||||
//public static int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
public static string FileUpload(string pageVersion, string memberGuid) {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Create(int parentID) {
|
||||
string _body = HttpContext.Current.Request["body"];
|
||||
string _title = HttpContext.Current.Request["title"];
|
||||
string _keywords = HttpContext.Current.Request["keywords"];
|
||||
|
||||
int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
if (parentID > 0 && _currentMember > 0) {
|
||||
|
||||
bool isAdmin = (Library.Xslt.IsInGroup("admin") || Library.Xslt.IsInGroup("wiki editor"));
|
||||
umbraco.cms.businesslogic.web.Document doc = new umbraco.cms.businesslogic.web.Document(parentID);
|
||||
bool isLocked = (doc.getProperty("umbracoNoEdit").Value.ToString() == "1");
|
||||
|
||||
if ((isAdmin || !isLocked) && doc.ContentType.Alias == "WikiPage") {
|
||||
Businesslogic.WikiPage wp = Businesslogic.WikiPage.Create(parentID, _currentMember, _body, _title, _keywords);
|
||||
return umbraco.library.NiceUrl(wp.NodeId);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Update(int ID) {
|
||||
int _currentMember = umbraco.cms.businesslogic.member.Member.CurrentMemberId();
|
||||
string _body = HttpContext.Current.Request["body"];
|
||||
string _title = HttpContext.Current.Request["title"];
|
||||
string _keywords = HttpContext.Current.Request["keywords"];
|
||||
|
||||
bool isAdmin = (Library.Xslt.IsInGroup("admin") || Library.Xslt.IsInGroup("wiki editor"));
|
||||
|
||||
if (ID > 0 && _currentMember > 0 && _body.Trim() != "" && _title.Trim() != "") {
|
||||
|
||||
Businesslogic.WikiPage wp = new uWiki.Businesslogic.WikiPage(ID);
|
||||
|
||||
if (wp.Exists && (isAdmin || !wp.Locked)) {
|
||||
|
||||
wp.Title = _title;
|
||||
wp.Author = _currentMember;
|
||||
wp.Body = _body;
|
||||
wp.Keywords = _keywords;
|
||||
wp.Save();
|
||||
|
||||
return umbraco.library.NiceUrl(wp.NodeId);
|
||||
}
|
||||
|
||||
return "not allowed " + isAdmin.ToString() + " " + wp.Locked + " " + wp.Exists;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static XPathNodeIterator GetContentVersion(int id, string guid) {
|
||||
return Xslt.GetXmlNodeFromVersion(id, guid, false);
|
||||
}
|
||||
|
||||
public static string Move(int ID, int target)
|
||||
{
|
||||
int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
if (Xslt.IsMemberInGroup("admin", _currentMember) || Xslt.IsMemberInGroup("wiki editor", _currentMember))
|
||||
{
|
||||
Document d = new Document(ID);
|
||||
Document t = new Document(target);
|
||||
|
||||
if(t.ContentType.Alias == "WikiPage"){
|
||||
|
||||
Document o = new Document(d.Parent.Id);
|
||||
|
||||
d.Move(t.Id);
|
||||
d.Save();
|
||||
|
||||
d.Publish(new umbraco.BusinessLogic.User(0));
|
||||
t.Publish(new umbraco.BusinessLogic.User(0));
|
||||
o.Publish(new umbraco.BusinessLogic.User(0));
|
||||
|
||||
umbraco.library.UpdateDocumentCache(d.Id);
|
||||
umbraco.library.UpdateDocumentCache(t.Id);
|
||||
umbraco.library.UpdateDocumentCache(o.Id);
|
||||
|
||||
umbraco.library.RefreshContent();
|
||||
|
||||
return umbraco.library.NiceUrl(d.Id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Delete(int ID)
|
||||
{
|
||||
int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
if (Xslt.IsMemberInGroup("admin", _currentMember) || Xslt.IsMemberInGroup("wiki editor", _currentMember))
|
||||
{
|
||||
Document d = new Document(ID);
|
||||
|
||||
if (d != null)
|
||||
{
|
||||
umbraco.library.UnPublishSingleNode(d.Id);
|
||||
d.delete();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static string VerifyFile(int ID)
|
||||
{
|
||||
int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
if (Xslt.IsMemberInGroup("admin", _currentMember))
|
||||
{
|
||||
WikiFile wf = new WikiFile(ID);
|
||||
wf.Verified = true;
|
||||
wf.Save();
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string Rollback(int ID, string guid) {
|
||||
|
||||
int _currentMember = HttpContext.Current.User.Identity.IsAuthenticated ? (int)Membership.GetUser().ProviderUserKey : 0;
|
||||
|
||||
umbraco.cms.businesslogic.web.Document olddoc = new umbraco.cms.businesslogic.web.Document(ID, new Guid(guid));
|
||||
Businesslogic.WikiPage wp = new uWiki.Businesslogic.WikiPage(ID);
|
||||
|
||||
if (olddoc != null && wp.Exists && !wp.Locked && _currentMember > 0 && wp.Version.ToString() != guid) {
|
||||
|
||||
wp.Body = olddoc.getProperty("bodyText").Value.ToString();
|
||||
wp.Title = olddoc.Text;
|
||||
wp.Author = _currentMember;
|
||||
wp.Save();
|
||||
|
||||
return umbraco.library.NiceUrl(wp.NodeId);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void ClearHelpRequests(string section, string applicationPage)
|
||||
{
|
||||
|
||||
Data.SqlHelper.ExecuteNonQuery(
|
||||
"Delete from wikiHelpRequest where section = @section and applicationPage = @applicationPage",
|
||||
Data.SqlHelper.CreateParameter("@section", section),
|
||||
Data.SqlHelper.CreateParameter("@applicationPage", applicationPage));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace uWiki.Library {
|
||||
);
|
||||
}
|
||||
|
||||
public static XPathNodeIterator GetXmlNodeFromVersion(int id, string guid, bool deep) {
|
||||
public static string GetXmlNodeFromVersion(int id, string guid, bool deep) {
|
||||
|
||||
Document d;
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace uWiki.Library {
|
||||
XmlNode x = umbraco.xmlHelper.addTextNode(xd, "node", "");
|
||||
d.XmlPopulate(xd, ref x, deep);
|
||||
|
||||
return x.CreateNavigator().Select(".");
|
||||
return x.OuterXml;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -225,6 +225,7 @@
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Api\WikiController.cs" />
|
||||
<Compile Include="Businesslogic\Data.cs" />
|
||||
<Compile Include="Businesslogic\Events.cs" />
|
||||
<Compile Include="Businesslogic\UmbracoVersion.cs" />
|
||||
@@ -232,7 +233,6 @@
|
||||
<Compile Include="Businesslogic\WikiHelpRequest.cs" />
|
||||
<Compile Include="Businesslogic\WikiPage.cs" />
|
||||
<Compile Include="iNotFoundHandler.cs" />
|
||||
<Compile Include="Library\rest.cs" />
|
||||
<Compile Include="Library\Utills.cs" />
|
||||
<Compile Include="Library\xslt.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
Reference in New Issue
Block a user