Fix small bug in new preview function.

https://github.com/sbrl/Pepperminty-Wiki/pull/140#issuecomment-31269952
This commit is contained in:
Starbeamrainbowlabs 2017-07-03 18:33:25 +01:00
parent 7e14eb609a
commit e3fcecdc1a
3 changed files with 85 additions and 85 deletions

View File

@ -5119,47 +5119,6 @@ register_module([
"code" => function() {
global $settings, $env;
/**
* @api {post} ?action=preview-edit&page={pageName}[&newpage=yes] Get a preview of the page
* @apiDescription Gets a preview of the current edit state of a given page
* @apiName PreviewPage
* @apiPermission Anonymous
*
* @apiUse PageParameter
* @apiParam {string} newpage Set to 'yes' if a new page is being created.
* @apiParam {string} preview-edit Set to a value to preview an edit of a page.
*/
/*
*
* ██████ ██████ ███████ ██ ██ ██ ███████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ █████ ██ ██ ██ █████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
* ██ ██ ██ ███████ ████ ██ ███████ ███ ███
*
* ███████ ██████ ██ ████████
* ██ ██ ██ ██ ██
* █████ ██ ██ ██ ██
* ██ ██ ██ ██ ██
* ███████ ██████ ██ ██
*
*/
add_action("preview-edit", function() {
global $pageindex, $settings, $env, $actions;
if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
// preview changes
get_object_vars($actions)['edit']();
}
else {
// save page
get_object_vars($actions)['save']();
}
});
/**
* @api {get} ?action=edit&page={pageName}[&newpage=yes] Get an editing page
@ -5282,7 +5241,7 @@ register_module([
}
$content .= "<form method='post' name='edit-form' action='index.php?action=preview-edit&page=' class='editform'>
$content .= "<form method='post' name='edit-form' action='index.php?action=preview-edit&page=$env->page' class='editform'>
<input type='hidden' name='prev-content-hash' value='" . ((isset($old_pagetext)) ? sha1($old_pagetext) : sha1($pagetext)) . "' />
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
<pre class='fit-text-mirror'></pre>
@ -5343,6 +5302,47 @@ window.addEventListener("load", function(event) {
exit(page_renderer::render_main("$title - $settings->sitename", $content));
});
/**
* @api {post} ?action=preview-edit&page={pageName}[&newpage=yes] Get a preview of the page
* @apiDescription Gets a preview of the current edit state of a given page
* @apiName PreviewPage
* @apiPermission Anonymous
*
* @apiUse PageParameter
* @apiParam {string} newpage Set to 'yes' if a new page is being created.
* @apiParam {string} preview-edit Set to a value to preview an edit of a page.
*/
/*
*
* ██████ ██████ ███████ ██ ██ ██ ███████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ █████ ██ ██ ██ █████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
* ██ ██ ██ ███████ ████ ██ ███████ ███ ███
*
* ███████ ██████ ██ ████████
* ██ ██ ██ ██ ██
* █████ ██ ██ ██ ██
* ██ ██ ██ ██ ██
* ███████ ██████ ██ ██
*
*/
add_action("preview-edit", function() {
global $pageindex, $settings, $env, $actions;
if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
// preview changes
get_object_vars($actions)['edit']();
}
else {
// save page
get_object_vars($actions)['save']();
}
});
/**
* @api {post} ?action=save&page={pageName} Save an edit to a page.
* @apiDescription Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.

View File

@ -158,7 +158,7 @@
"author": "Starbeamrainbowlabs",
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
"id": "page-edit",
"lastupdate": 1499102583,
"lastupdate": 1499103162,
"optional": false
},
{

View File

@ -8,47 +8,6 @@ register_module([
"code" => function() {
global $settings, $env;
/**
* @api {post} ?action=preview-edit&page={pageName}[&newpage=yes] Get a preview of the page
* @apiDescription Gets a preview of the current edit state of a given page
* @apiName PreviewPage
* @apiPermission Anonymous
*
* @apiUse PageParameter
* @apiParam {string} newpage Set to 'yes' if a new page is being created.
* @apiParam {string} preview-edit Set to a value to preview an edit of a page.
*/
/*
*
* ██████ ██████ ███████ ██ ██ ██ ███████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ █████ ██ ██ ██ █████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
* ██ ██ ██ ███████ ████ ██ ███████ ███ ███
*
* ███████ ██████ ██ ████████
* ██ ██ ██ ██ ██
* █████ ██ ██ ██ ██
* ██ ██ ██ ██ ██
* ███████ ██████ ██ ██
*
*/
add_action("preview-edit", function() {
global $pageindex, $settings, $env, $actions;
if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
// preview changes
get_object_vars($actions)['edit']();
}
else {
// save page
get_object_vars($actions)['save']();
}
});
/**
* @api {get} ?action=edit&page={pageName}[&newpage=yes] Get an editing page
@ -171,7 +130,7 @@ register_module([
}
$content .= "<form method='post' name='edit-form' action='index.php?action=preview-edit&page=' class='editform'>
$content .= "<form method='post' name='edit-form' action='index.php?action=preview-edit&page=$env->page' class='editform'>
<input type='hidden' name='prev-content-hash' value='" . ((isset($old_pagetext)) ? sha1($old_pagetext) : sha1($pagetext)) . "' />
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
<pre class='fit-text-mirror'></pre>
@ -232,6 +191,47 @@ window.addEventListener("load", function(event) {
exit(page_renderer::render_main("$title - $settings->sitename", $content));
});
/**
* @api {post} ?action=preview-edit&page={pageName}[&newpage=yes] Get a preview of the page
* @apiDescription Gets a preview of the current edit state of a given page
* @apiName PreviewPage
* @apiPermission Anonymous
*
* @apiUse PageParameter
* @apiParam {string} newpage Set to 'yes' if a new page is being created.
* @apiParam {string} preview-edit Set to a value to preview an edit of a page.
*/
/*
*
* ██████ ██████ ███████ ██ ██ ██ ███████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██████ ██████ █████ ██ ██ ██ █████ ██ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██
* ██ ██ ██ ███████ ████ ██ ███████ ███ ███
*
* ███████ ██████ ██ ████████
* ██ ██ ██ ██ ██
* █████ ██ ██ ██ ██
* ██ ██ ██ ██ ██
* ███████ ██████ ██ ██
*
*/
add_action("preview-edit", function() {
global $pageindex, $settings, $env, $actions;
if(isset($_POST['preview-edit']) && isset($_POST['content'])) {
// preview changes
get_object_vars($actions)['edit']();
}
else {
// save page
get_object_vars($actions)['save']();
}
});
/**
* @api {post} ?action=save&page={pageName} Save an edit to a page.
* @apiDescription Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.