mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
For #204: Implement initial (untested!) page history algorithm.
TODO: Search for existing page history revisions
This commit is contained in:
parent
3b799cbcba
commit
6e7ff16041
1 changed files with 15 additions and 1 deletions
|
@ -8,6 +8,7 @@ if(!file_exists($paths->pageindex))
|
|||
{
|
||||
$glob_str = $env->storage_prefix . "*.md";
|
||||
$existingpages = glob_recursive($glob_str);
|
||||
$existingpages_count = count($existingpages);
|
||||
// Debug statements. Uncomment when debugging the pageindex regenerator.
|
||||
// var_dump($env->storage_prefix);
|
||||
// var_dump($glob_str);
|
||||
|
@ -15,7 +16,7 @@ if(!file_exists($paths->pageindex))
|
|||
$pageindex = new stdClass();
|
||||
// We use a for loop here because foreach doesn't loop over new values inserted
|
||||
// while we were looping
|
||||
for($i = 0; $i < count($existingpages); $i++)
|
||||
for($i = 0; $i < $existingpages_count; $i++)
|
||||
{
|
||||
$pagefilename = $existingpages[$i];
|
||||
|
||||
|
@ -77,6 +78,19 @@ if(!file_exists($paths->pageindex))
|
|||
}
|
||||
}
|
||||
|
||||
if(function_exists("history_add_revision") && !file_exists("{$pagefilename}.r0")) { // Can't use module_exists - too early
|
||||
copy($pagefilename, "{$pagefilename}.r0");
|
||||
$newentry->history = [ (object) [
|
||||
"type" => "edit",
|
||||
"rid" => 0,
|
||||
"timestamp" => $newentry->lastmodified,
|
||||
"filename" => "{$pagefilename}.r0",
|
||||
"newsize" => $newentry->size,
|
||||
"sizediff" => $newentry->size,
|
||||
"editor" => "unknown"
|
||||
] ];
|
||||
}
|
||||
|
||||
// Store the new entry in the new page index
|
||||
$pageindex->$pagekey = $newentry;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue