1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Delete page names from the id index upon page deletion.

This commit is contained in:
Starbeamrainbowlabs 2015-11-11 19:24:40 +00:00
parent 43d15f9212
commit 6eea1700d6
4 changed files with 65 additions and 9 deletions

View file

@ -771,6 +771,11 @@ class ids
return $idindex->$id;
}
/*
* @summary Moves a page in the id index from $oldpagename to $newpagename.
* Note that this function doesn't perform any special checks to
* make sure that the destination name doesn't already exist.
*/
public static function movepagename($oldpagename, $newpagename)
{
global $idindex, $paths;
@ -781,6 +786,22 @@ class ids
file_put_contents($paths->idindex, json_encode($idindex));
}
/*
* @summary Removes the given page name from the id index. Note that this
* function doesn't handle multiple entries with the same name.
*/
public static function deletepagename($pagename)
{
global $idindex, $paths;
// Get the id of the specified page
$pageid = self::getid($pagename);
// Remove it from the pageindex
unset($idindex->$pageid);
// Save the id index
file_put_contents($paths->idindex, json_encode($idindex));
}
/*
* @summary Assigns an id to a pagename. Doesn't check to make sure that
* pagename doesn't exist in the pageindex.
@ -2329,9 +2350,16 @@ register_module([
{
unlink($env->storage_prefix . $pageindex->$page->uploadedfilepath);
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("$env->storage_prefix$env->page.md"); //delete the page from the disk
// Delete the page from the page index
unset($pageindex->$page);
// Save the new page index
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
// Remove the page's name from the id index
ids::deletepagename($env->page);
// Delete the page from the disk
unlink("$env->storage_prefix$env->page.md");
exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "<p>$env->page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
});

View file

@ -433,6 +433,11 @@ class ids
return $idindex->$id;
}
/*
* @summary Moves a page in the id index from $oldpagename to $newpagename.
* Note that this function doesn't perform any special checks to
* make sure that the destination name doesn't already exist.
*/
public static function movepagename($oldpagename, $newpagename)
{
global $idindex, $paths;
@ -443,6 +448,22 @@ class ids
file_put_contents($paths->idindex, json_encode($idindex));
}
/*
* @summary Removes the given page name from the id index. Note that this
* function doesn't handle multiple entries with the same name.
*/
public static function deletepagename($pagename)
{
global $idindex, $paths;
// Get the id of the specified page
$pageid = self::getid($pagename);
// Remove it from the pageindex
unset($idindex->$pageid);
// Save the id index
file_put_contents($paths->idindex, json_encode($idindex));
}
/*
* @summary Assigns an id to a pagename. Doesn't check to make sure that
* pagename doesn't exist in the pageindex.

View file

@ -77,7 +77,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds an action to allow administrators to delete pages.",
"id": "page-delete",
"lastupdate": 1447053826,
"lastupdate": 1447269808,
"optional": false
},
{

View file

@ -32,9 +32,16 @@ register_module([
{
unlink($env->storage_prefix . $pageindex->$page->uploadedfilepath);
}
unset($pageindex->$page); //delete the page from the page index
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT)); //save the new page index
unlink("$env->storage_prefix$env->page.md"); //delete the page from the disk
// Delete the page from the page index
unset($pageindex->$page);
// Save the new page index
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
// Remove the page's name from the id index
ids::deletepagename($env->page);
// Delete the page from the disk
unlink("$env->storage_prefix$env->page.md");
exit(page_renderer::render_main("Deleting $env->page - $settings->sitename", "<p>$env->page has been deleted. <a href='index.php'>Go back to the main page</a>.</p>"));
});