mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-26 05:32:59 +00:00
Fix small bug in new preview function.
https://github.com/sbrl/Pepperminty-Wiki/pull/140#issuecomment-31269952
This commit is contained in:
parent
7e14eb609a
commit
e3fcecdc1a
3 changed files with 85 additions and 85 deletions
|
@ -5120,47 +5120,6 @@ register_module([
|
||||||
"code" => function() {
|
"code" => function() {
|
||||||
global $settings, $env;
|
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
|
* @api {get} ?action=edit&page={pageName}[&newpage=yes] Get an editing page
|
||||||
* @apiDescription Gets an editing page for a given page. If you don't have permission to edit the page in question, a view source pagee is returned instead.
|
* @apiDescription Gets an editing page for a given page. If you don't have permission to edit the page in question, a view source pagee is returned instead.
|
||||||
|
@ -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)) . "' />
|
<input type='hidden' name='prev-content-hash' value='" . ((isset($old_pagetext)) ? sha1($old_pagetext) : sha1($pagetext)) . "' />
|
||||||
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
|
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
|
||||||
<pre class='fit-text-mirror'></pre>
|
<pre class='fit-text-mirror'></pre>
|
||||||
|
@ -5343,6 +5302,47 @@ window.addEventListener("load", function(event) {
|
||||||
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
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.
|
* @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.
|
* @apiDescription Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.
|
||||||
|
|
|
@ -158,7 +158,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
"description": "Allows you to edit pages by adding the edit and save actions. You should probably include this one.",
|
||||||
"id": "page-edit",
|
"id": "page-edit",
|
||||||
"lastupdate": 1499102583,
|
"lastupdate": 1499103162,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,47 +9,6 @@ register_module([
|
||||||
"code" => function() {
|
"code" => function() {
|
||||||
global $settings, $env;
|
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
|
* @api {get} ?action=edit&page={pageName}[&newpage=yes] Get an editing page
|
||||||
* @apiDescription Gets an editing page for a given page. If you don't have permission to edit the page in question, a view source pagee is returned instead.
|
* @apiDescription Gets an editing page for a given page. If you don't have permission to edit the page in question, a view source pagee is returned instead.
|
||||||
|
@ -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)) . "' />
|
<input type='hidden' name='prev-content-hash' value='" . ((isset($old_pagetext)) ? sha1($old_pagetext) : sha1($pagetext)) . "' />
|
||||||
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
|
<textarea name='content' autofocus tabindex='1'>$pagetext</textarea>
|
||||||
<pre class='fit-text-mirror'></pre>
|
<pre class='fit-text-mirror'></pre>
|
||||||
|
@ -232,6 +191,47 @@ window.addEventListener("load", function(event) {
|
||||||
exit(page_renderer::render_main("$title - $settings->sitename", $content));
|
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.
|
* @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.
|
* @apiDescription Saves an edit to a page. If an edit conflict is encountered, then a conflict resolution page is returned instead.
|
||||||
|
|
Loading…
Reference in a new issue