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);
};
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") );
$(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",
pageName,
oldRevision,
fldPageName.value,
+ chkIsLocked.checked,
"text/x-rakka",
fldSummary.value,
fldRakkaSource.value);
pageName,
oldRevision,
fldPageName.value,
+ chkIsLocked.checked,
"text/css",
fldSummary.value,
fldCSSSource.value);
pageName,
oldRevision,
fldPageName.value,
+ chkIsLocked.checked,
fldSummary.value,
fldUploadFile.value);
}
pageName,
oldRevision,
fldPageName.value,
+ chkIsLocked.checked,
fldRedirect.value);
}
});
$.TH({}, "Page name"),
$.TD({}, fldPageName)
),
+ trIsLocked,
$.TR({},
$.TH({}, "Page type"),
$.TD({},
$area.append(pageEditor);
+ if (!Rakka.isLoggedIn() || Rakka.isGlobalLocked) {
+ $(trIsLocked).hide();
+ }
+
isDirty = false;
};
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);
page.appendChild(updateInfo);
}
+ page.setAttribute("isLocked", isLocked ? "yes" : "no");
page.setAttribute("type", mimeType);
if (summary != null) {
});
};
- 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);
page.appendChild(updateInfo);
}
+ page.setAttribute("isLocked", isLocked ? "yes" : "no");
page.setAttribute("type", "");
if (summary != null) {
});
};
- 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);
page.appendChild(updateInfo);
}
+ page.setAttribute("isLocked", isLocked ? "yes" : "no");
page.setAttribute("redirect", destination);
Rakka.displayWaitingMessage("Submitting... please wait.");