MDL-22176 backup & restore links - Added support for course encoder
This commit is contained in:
@@ -103,6 +103,23 @@ class backup_course_task extends backup_task {
|
||||
$this->built = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Code the transformations to perform in the course in
|
||||
* order to get transportable (encoded) links
|
||||
*/
|
||||
static public function encode_content_links($content) {
|
||||
global $CFG;
|
||||
|
||||
$base = preg_quote($CFG->wwwroot,"/");
|
||||
|
||||
// Link to the course main page (it also covers "&topic=xx" and "&week=xx"
|
||||
// because they don't become transformed (section number) in backup/restore
|
||||
$search = '/(' . $base . '\/course\/view.php\?id\=)([0-9]+)/';
|
||||
$content= preg_replace($search, '$@COURSEVIEWBYID*$2@$', $content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
/**
|
||||
|
||||
@@ -110,7 +110,10 @@ class backup_xml_transformer extends xml_contenttransformer {
|
||||
private function register_link_encoders() {
|
||||
$encoders = array();
|
||||
|
||||
// First of all, add the module ones. Each module supporting moodle2 backups MUST have it
|
||||
// Add the course encoder
|
||||
$encoders['backup_course_task'] = 'encode_content_links';
|
||||
|
||||
// Add the module ones. Each module supporting moodle2 backups MUST have it
|
||||
$mods = get_plugin_list('mod');
|
||||
foreach ($mods as $mod => $moddir) {
|
||||
if (plugin_supports('mod', $mod, FEATURE_BACKUP_MOODLE2)) {
|
||||
@@ -118,7 +121,7 @@ class backup_xml_transformer extends xml_contenttransformer {
|
||||
}
|
||||
}
|
||||
|
||||
// Add the block encodes
|
||||
// Add the block encoders
|
||||
$blocks = get_plugin_list('block');
|
||||
foreach ($blocks as $block => $blockdir) {
|
||||
if (class_exists('backup_' . $block . '_block_task')) {
|
||||
|
||||
Reference in New Issue
Block a user