Skip to content

Commit

Permalink
Converting wiki to markdown in old (<2005041100) courses.
Browse files Browse the repository at this point in the history
First step. Launcher created.
  • Loading branch information
stronk7 committed Apr 12, 2005
1 parent a809375 commit 8057882
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions backup/restore_execute.html
Expand Up @@ -13,6 +13,9 @@
//Add info->original_wwwroot to $restore to be able to use it in all the restore process
//(mainly when decoding internal links)
$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
require_login();
Expand Down Expand Up @@ -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:
// - course modinfo field
// - categories table
Expand Down
24 changes: 24 additions & 0 deletions backup/restorelib.php
Expand Up @@ -93,6 +93,30 @@ function restore_decode_content_links($restore) {
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
//decode them to their new ids.
function restore_decode_wiki_texts($restore) {
Expand Down

0 comments on commit 8057882

Please sign in to comment.