X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=js%2FeditPage.js;h=5948d6dc94bfb30fa62c6003ac8e1fcc767fc22e;hb=b101c0a9aad609704eaa9157fe809be80d2aacf7;hp=d50e5b40c6003c32d2029285366c2e72dd23886a;hpb=443af4d3304139bb2187a0c726327b9c05829810;p=Rakka.git diff --git a/js/editPage.js b/js/editPage.js index d50e5b4..5948d6d 100644 --- a/js/editPage.js +++ b/js/editPage.js @@ -15,29 +15,35 @@ url : Rakka.baseURI + pageName + ".xml", success: function (pageXml) { Rakka.hideWaitingMessage(); - - var $page = $(pageXml).find("page"); - var oldRevision = $page.attr("revision"); - var defaultType - = $page.attr("isBinary") == "yes" ? "binary" - : $page.attr("type") == "text/x-rakka" ? "rakka" - : $page.attr("type") == "text/css" ? "css" - : $page.attr("redirect") != null ? "redirect" - : "unknown" - ; - var source - = $page.attr("redirect") != null ? $page.attr("redirect") - : $page.find("textData").text() - ; - var summary = $page.find("summary").text(); + + if (pageXml.documentElement.tagName == "page") { + var $page = $(pageXml).find("page"); + var oldRevision = $page.attr("revision"); + var defaultType + = $page.attr("isBinary") == "yes" ? "binary" + : $page.attr("type") == "text/x-rakka" ? "rakka" + : $page.attr("type") == "text/css" ? "css" + : $page.attr("redirect") != null ? "redirect" + : "unknown" + ; + var isLocked = $page.attr("isLocked") == "yes"; + var source + = $page.attr("redirect") != null ? $page.attr("redirect") + : $page.find("textData").text() + ; + var summary = $page.find("summary").text(); - displayPageEditor(pageName, oldRevision, defaultType, source, summary); + displayPageEditor(pageName, oldRevision, defaultType, isLocked, source, summary); + } + else { + displayPageEditor(pageName, null, "rakka", false, null, ""); + } }, error : function (req) { Rakka.hideWaitingMessage(); if (req.status == 404) { - displayPageEditor(pageName, null, "rakka", null, ""); + displayPageEditor(pageName, null, "rakka", false, null, ""); } else { $area.text("Error: " + req.status + " " + req.statusText); @@ -47,10 +53,10 @@ }; Rakka.newPage = function () { - displayPageEditor("", null, "rakka", null, ""); + displayPageEditor("", null, "rakka", false, null, ""); }; - var displayPageEditor = function (pageName, oldRevision, defaultType, source, summary) { + var displayPageEditor = function (pageName, oldRevision, defaultType, isLocked, source, summary) { var $area = Rakka.switchScreen(); $previewHeader = $( $.H1({}, "Preview") ); @@ -72,6 +78,20 @@ $(fldPageName).change(makeDirty); + var chkIsLocked + = $.INPUT({type : "checkbox", + checked : (isLocked ? "checked" : "")}); + + $(chkIsLocked).change(makeDirty); + + var trIsLocked + = $.TR({}, + $.TH({}, "Page lock"), + $.TD({}, + $.LABEL({}, + chkIsLocked, + "Disallow anonymous users to edit or delete this page"))); + var btnTypeRakka = $.INPUT({type : "radio", name : "type", @@ -161,6 +181,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/x-rakka", fldSummary.value, fldRakkaSource.value); @@ -170,6 +191,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, "text/css", fldSummary.value, fldCSSSource.value); @@ -179,6 +201,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldSummary.value, fldUploadFile.value); } @@ -187,6 +210,7 @@ pageName, oldRevision, fldPageName.value, + chkIsLocked.checked, fldRedirect.value); } }); @@ -253,6 +277,7 @@ $.TH({}, "Page name"), $.TD({}, fldPageName) ), + trIsLocked, $.TR({}, $.TH({}, "Page type"), $.TD({}, @@ -300,6 +325,10 @@ $area.append(pageEditor); + if (!Rakka.isLoggedIn() || Rakka.isGlobalLocked) { + $(trIsLocked).hide(); + } + isDirty = false; }; @@ -365,7 +394,7 @@ Rakka.scrollToTopLeft(); }; - var submitTextPage = function (pageName, oldRevision, givenPageName, mimeType, summary, text) { + var submitTextPage = function (pageName, oldRevision, givenPageName, isLocked, mimeType, summary, text) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -385,6 +414,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", mimeType); if (summary != null) { @@ -424,7 +454,7 @@ }); }; - var submitBinaryPage = function (pageName, oldRevision, givenPageName, summary, path) { + var submitBinaryPage = function (pageName, oldRevision, givenPageName, isLocked, summary, path) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -444,6 +474,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("type", ""); if (summary != null) { @@ -486,7 +517,7 @@ }); }; - var submitRedirection = function (pageName, oldRevision, givenPageName, destination) { + var submitRedirection = function (pageName, oldRevision, givenPageName, isLocked, destination) { var doc = document.implementation.createDocument( "http://cielonegro.org/schema/Rakka/Page/1.0", "page", null); @@ -506,6 +537,7 @@ page.appendChild(updateInfo); } + page.setAttribute("isLocked", isLocked ? "yes" : "no"); page.setAttribute("redirect", destination); Rakka.displayWaitingMessage("Submitting... please wait.");