Switch over another stray path in the core to the new system

This commit is contained in:
Starbeamrainbowlabs 2015-11-12 10:01:21 +00:00
parent 414eb58850
commit 9c1b5faf28
4 changed files with 11 additions and 11 deletions

View File

@ -540,11 +540,11 @@ function get_subpages($pageindex, $pagename)
*/ */
function check_subpage_parents($pagename) function check_subpage_parents($pagename)
{ {
global $pageindex; global $pageindex, $paths;
// Save the new pageindex and return if there aren't any more parent pages to check // Save the new pageindex and return if there aren't any more parent pages to check
if(strpos($pagename, "/") === false) if(strpos($pagename, "/") === false)
{ {
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
return; return;
} }
@ -1232,7 +1232,7 @@ register_module([
{ {
// They check out ok, toggle the page's protection. // They check out ok, toggle the page's protection.
$page = $env->page; $page = $env->page;
if(!isset($pageindex->$page->protect)) if(!isset($pageindex->$page->protect))
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
@ -1245,10 +1245,10 @@ register_module([
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
} }
// Save the pageindex // Save the pageindex
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT)); file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
$state = ($pageindex->$page->protect ? "enabled" : "disabled"); $state = ($pageindex->$page->protect ? "enabled" : "disabled");
$title = "Page protection $state."; $title = "Page protection $state.";
exit(page_renderer::render_main($title, "<p>Page protection for $env->page has been $state.</p><p><a href='?action=$settings->defaultaction&page=$env->page'>Go back</a>.")); exit(page_renderer::render_main($title, "<p>Page protection for $env->page has been $state.</p><p><a href='?action=$settings->defaultaction&page=$env->page'>Go back</a>."));

View File

@ -202,11 +202,11 @@ function get_subpages($pageindex, $pagename)
*/ */
function check_subpage_parents($pagename) function check_subpage_parents($pagename)
{ {
global $pageindex; global $pageindex, $paths;
// Save the new pageindex and return if there aren't any more parent pages to check // Save the new pageindex and return if there aren't any more parent pages to check
if(strpos($pagename, "/") === false) if(strpos($pagename, "/") === false)
{ {
file_put_contents("./pageindex.json", json_encode($pageindex, JSON_PRETTY_PRINT)); file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
return; return;
} }

View File

@ -14,7 +14,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.", "description": "Exposes Pepperminty Wiki's new page protection mechanism and makes the protect button in the 'More...' menu on the top bar work.",
"id": "action-protect", "id": "action-protect",
"lastupdate": 1447322278, "lastupdate": 1447322382,
"optional": false "optional": false
}, },
{ {

View File

@ -14,7 +14,7 @@ register_module([
{ {
// They check out ok, toggle the page's protection. // They check out ok, toggle the page's protection.
$page = $env->page; $page = $env->page;
if(!isset($pageindex->$page->protect)) if(!isset($pageindex->$page->protect))
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
@ -27,10 +27,10 @@ register_module([
{ {
$pageindex->$page->protect = true; $pageindex->$page->protect = true;
} }
// Save the pageindex // Save the pageindex
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT)); file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
$state = ($pageindex->$page->protect ? "enabled" : "disabled"); $state = ($pageindex->$page->protect ? "enabled" : "disabled");
$title = "Page protection $state."; $title = "Page protection $state.";
exit(page_renderer::render_main($title, "<p>Page protection for $env->page has been $state.</p><p><a href='?action=$settings->defaultaction&page=$env->page'>Go back</a>.")); exit(page_renderer::render_main($title, "<p>Page protection for $env->page has been $state.</p><p><a href='?action=$settings->defaultaction&page=$env->page'>Go back</a>."));