mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Make move action aware of page revisions
This commit is contained in:
parent
44480edb54
commit
9f5e52d76f
3 changed files with 40 additions and 4 deletions
|
@ -4225,7 +4225,7 @@ register_module([
|
|||
exit(page_renderer::render_main("Moving $env->page - Error - $settings->sitename", "<p>Whilst moving the file associated with $env->page, $settings->sitename detected a pre-existing file on the server's file system. Because $settings->sitename can't determine whether the existing file is important to another component of $settings->sitename or it's host web server, the move have been aborted - just in case.</p>
|
||||
<p>If you know that this move is actually safe, please get your site administrator (" . $settings->admindetails["name"] . ") to perform the move manually. Their contact address can be found at the bottom of every page (including this one).</p>"));
|
||||
|
||||
//move the page in the page index
|
||||
// Move the page in the page index
|
||||
$pageindex->$new_name = new stdClass();
|
||||
foreach($pageindex->$page as $key => $value)
|
||||
{
|
||||
|
@ -4233,6 +4233,7 @@ register_module([
|
|||
}
|
||||
unset($pageindex->$page);
|
||||
$pageindex->$new_name->filename = $new_name;
|
||||
|
||||
// If this page has an associated file, then we should move that too
|
||||
if(!empty($pageindex->$new_name->uploadedfile))
|
||||
{
|
||||
|
@ -4243,6 +4244,23 @@ register_module([
|
|||
// Move the file on disk
|
||||
rename($env->storage_prefix . $env->page, $env->storage_prefix . $new_name);
|
||||
}
|
||||
|
||||
// Come to think about it, we should probably move the history while we're at it
|
||||
foreach($pageindex->$new_name->history as &$revisionData)
|
||||
{
|
||||
// We're only interested in edits
|
||||
if($revisionData->type !== "edit") continue;
|
||||
$newRevisionName = $pageindex->$new_name->filename . ".r$revisionData->rid";
|
||||
// Move the revision to it's new name
|
||||
rename(
|
||||
$env->storage_prefix . $revisionData->filename,
|
||||
$env->storage_prefix . $newRevisionName
|
||||
);
|
||||
// Update the pageindex entry
|
||||
$revisionData->filename = $newRevisionName;
|
||||
}
|
||||
|
||||
// Save the updated pageindex
|
||||
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
|
||||
|
||||
// Move the page on the disk
|
||||
|
|
|
@ -167,7 +167,7 @@
|
|||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds an action to allow administrators to move pages.",
|
||||
"id": "page-move",
|
||||
"lastupdate": 1459628404,
|
||||
"lastupdate": 1465133466,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
register_module([
|
||||
"name" => "Page mover",
|
||||
"version" => "0.8.1",
|
||||
"version" => "0.9",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds an action to allow administrators to move pages.",
|
||||
"id" => "page-move",
|
||||
|
@ -60,7 +60,7 @@ register_module([
|
|||
exit(page_renderer::render_main("Moving $env->page - Error - $settings->sitename", "<p>Whilst moving the file associated with $env->page, $settings->sitename detected a pre-existing file on the server's file system. Because $settings->sitename can't determine whether the existing file is important to another component of $settings->sitename or it's host web server, the move have been aborted - just in case.</p>
|
||||
<p>If you know that this move is actually safe, please get your site administrator (" . $settings->admindetails["name"] . ") to perform the move manually. Their contact address can be found at the bottom of every page (including this one).</p>"));
|
||||
|
||||
//move the page in the page index
|
||||
// Move the page in the page index
|
||||
$pageindex->$new_name = new stdClass();
|
||||
foreach($pageindex->$page as $key => $value)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ register_module([
|
|||
}
|
||||
unset($pageindex->$page);
|
||||
$pageindex->$new_name->filename = $new_name;
|
||||
|
||||
// If this page has an associated file, then we should move that too
|
||||
if(!empty($pageindex->$new_name->uploadedfile))
|
||||
{
|
||||
|
@ -78,6 +79,23 @@ register_module([
|
|||
// Move the file on disk
|
||||
rename($env->storage_prefix . $env->page, $env->storage_prefix . $new_name);
|
||||
}
|
||||
|
||||
// Come to think about it, we should probably move the history while we're at it
|
||||
foreach($pageindex->$new_name->history as &$revisionData)
|
||||
{
|
||||
// We're only interested in edits
|
||||
if($revisionData->type !== "edit") continue;
|
||||
$newRevisionName = $pageindex->$new_name->filename . ".r$revisionData->rid";
|
||||
// Move the revision to it's new name
|
||||
rename(
|
||||
$env->storage_prefix . $revisionData->filename,
|
||||
$env->storage_prefix . $newRevisionName
|
||||
);
|
||||
// Update the pageindex entry
|
||||
$revisionData->filename = $newRevisionName;
|
||||
}
|
||||
|
||||
// Save the updated pageindex
|
||||
file_put_contents($paths->pageindex, json_encode($pageindex, JSON_PRETTY_PRINT));
|
||||
|
||||
// Move the page on the disk
|
||||
|
|
Loading…
Reference in a new issue