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:
parent
43d15f9212
commit
6eea1700d6
4 changed files with 65 additions and 9 deletions
|
@ -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;
|
||||
|
@ -780,6 +785,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
|
||||
|
@ -2329,10 +2350,17 @@ 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>"));
|
||||
});
|
||||
}
|
||||
|
|
21
core.php
21
core.php
|
@ -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;
|
||||
|
@ -442,6 +447,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
|
||||
|
|
|
@ -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
|
||||
},
|
||||
{
|
||||
|
|
|
@ -32,10 +32,17 @@ 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>"));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue