Converting wiki to markdown in old (<2005041100) courses.

First step. Launcher created.
This commit is contained in:
stronk7 2005-04-12 16:10:47 +00:00
parent a8093758b1
commit 805788218b
2 changed files with 36 additions and 0 deletions

View File

@ -13,6 +13,9 @@
//Add info->original_wwwroot to $restore to be able to use it in all the restore process //Add info->original_wwwroot to $restore to be able to use it in all the restore process
//(mainly when decoding internal links) //(mainly when decoding internal links)
$restore->original_wwwroot = $info->original_wwwroot; $restore->original_wwwroot = $info->original_wwwroot;
//Add info->backup_version to $restore to be able to detect versions in the restore process
//(to decide when to convert wiki texts to markdown...)
$restore->backup_version = $info->backup_backup_version;
//Check login //Check login
require_login(); require_login();
@ -330,6 +333,15 @@
} }
} }
//Now, with backup files prior to version 2005041100,
//convert all the wiki texts in the course to markdown
if ($status && $restore->backup_version < 2005041100) {
echo "<li>".get_string("convertingwikitomarkdown");
if (!$status = restore_convert_wiki2markdown($restore)) {
notify("Could not convert wiki texts to markdown!");
}
}
//Now if all is OK, update: //Now if all is OK, update:
// - course modinfo field // - course modinfo field
// - categories table // - categories table

View File

@ -93,6 +93,30 @@
return $status; return $status;
} }
//This function converts all the wiki texts in the restored course
//to the Markdown format. Used only for backup files prior 2005041100.
//It calls every module xxxx_convert_wiki2markdown function
function restore_convert_wiki2markdown($restore) {
$status = true;
echo "<ul>";
foreach ($restore->mods as $name => $info) {
//If the module is being restored
if ($info->restore == 1) {
//Check if the xxxx_convert_wiki2markdown exists
$function_name = $name."_convert_wiki2markdown";
if (function_exists($function_name)) {
echo "<li>".get_string("modulenameplural",$name);
$status = $function_name($restore);
echo '</li>';
}
}
}
return $status;
}
//This function search for some wiki texts in differenct parts of Moodle to //This function search for some wiki texts in differenct parts of Moodle to
//decode them to their new ids. //decode them to their new ids.
function restore_decode_wiki_texts($restore) { function restore_decode_wiki_texts($restore) {