mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-21 16:13:00 +00:00
Add (untested) support for save preprocessors.
This commit is contained in:
parent
bba4833688
commit
1f1d1cd685
4 changed files with 37 additions and 5 deletions
|
@ -832,6 +832,15 @@ function add_parser($parser_code)
|
|||
$parse_page_source = $parser_code;
|
||||
}
|
||||
|
||||
// Function to register a new proprocessor that will be executed just before
|
||||
// an edit is saved.
|
||||
$save_preprocessors = [];
|
||||
function register_save_preprocessor($func)
|
||||
{
|
||||
global $save_preprocessors;
|
||||
$save_processessors[] = $func;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
@ -1222,7 +1231,7 @@ register_module([
|
|||
* %save%
|
||||
*/
|
||||
add_action("save", function() {
|
||||
global $pageindex, $settings, $env;
|
||||
global $pageindex, $settings, $env, $save_preprocessors;
|
||||
if(!$settings->editing)
|
||||
{
|
||||
header("location: index.php?page=$env->page");
|
||||
|
@ -1248,8 +1257,15 @@ register_module([
|
|||
mkdir(dirname("$env->page.md"), null, true);
|
||||
}
|
||||
|
||||
$pagedata = htmlentities($_POST["content"], ENT_QUOTES);
|
||||
|
||||
if(file_put_contents("$env->page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
|
||||
// Execute all the preprocessors
|
||||
foreach($save_preprocessors as $func)
|
||||
{
|
||||
$func($pagedata);
|
||||
}
|
||||
|
||||
if(file_put_contents("$env->page.md", $pagedata) !== false)
|
||||
{
|
||||
$page = $env->page;
|
||||
// Make sure that this page's parents exist
|
||||
|
|
9
core.php
9
core.php
|
@ -599,6 +599,15 @@ function add_parser($parser_code)
|
|||
$parse_page_source = $parser_code;
|
||||
}
|
||||
|
||||
// Function to register a new proprocessor that will be executed just before
|
||||
// an edit is saved.
|
||||
$save_preprocessors = [];
|
||||
function register_save_preprocessor($func)
|
||||
{
|
||||
global $save_preprocessors;
|
||||
$save_processessors[] = $func;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,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": 1443591764,
|
||||
"lastupdate": 1443596864,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ register_module([
|
|||
* %save%
|
||||
*/
|
||||
add_action("save", function() {
|
||||
global $pageindex, $settings, $env;
|
||||
global $pageindex, $settings, $env, $save_preprocessors;
|
||||
if(!$settings->editing)
|
||||
{
|
||||
header("location: index.php?page=$env->page");
|
||||
|
@ -99,8 +99,15 @@ register_module([
|
|||
mkdir(dirname("$env->page.md"), null, true);
|
||||
}
|
||||
|
||||
$pagedata = htmlentities($_POST["content"], ENT_QUOTES);
|
||||
|
||||
if(file_put_contents("$env->page.md", htmlentities($_POST["content"]), ENT_QUOTES) !== false)
|
||||
// Execute all the preprocessors
|
||||
foreach($save_preprocessors as $func)
|
||||
{
|
||||
$func($pagedata);
|
||||
}
|
||||
|
||||
if(file_put_contents("$env->page.md", $pagedata) !== false)
|
||||
{
|
||||
$page = $env->page;
|
||||
// Make sure that this page's parents exist
|
||||
|
|
Loading…
Reference in a new issue