backup_sloodle_activity_task.class.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. require_once($CFG->dirroot . '/mod/sloodle/backup/moodle2/backup_sloodle_stepslib.php');
  3. require_once($CFG->dirroot . '/mod/sloodle/backup/moodle2/backup_sloodle_settingslib.php');
  4. /**
  5. * sloodle backup task that provides all the settings and steps to perform one
  6. * complete backup of the activity
  7. */
  8. class backup_sloodle_activity_task extends backup_activity_task {
  9. /**
  10. * Define (add) particular settings this activity can have
  11. */
  12. protected function define_my_settings() {
  13. // No particular settings for this activity
  14. }
  15. /**
  16. * Define (add) particular steps this activity can have
  17. */
  18. protected function define_my_steps() {
  19. // Choice only has one structure step
  20. $this->add_step(new backup_sloodle_activity_structure_step('sloodle_structure', 'sloodle.xml'));
  21. }
  22. /**
  23. * Code the transformations to perform in the activity in
  24. * order to get transportable (encoded) links
  25. */
  26. static public function encode_content_links($content) {
  27. global $CFG;
  28. $base = preg_quote($CFG->wwwroot,"#");
  29. // Any links to our own pluginfile.php URLs should be turned into something generic.
  30. // These will then be reencoded on restore into whatever is needed for that site.
  31. // Example:
  32. // http://gershwinklata1.avatarclassroom.com/pluginfile.php/408/mod_sloodle/presenter/1340348485/edmanga.jpg</source>
  33. if (preg_match('#^'.$base.'(/pluginfile.php/)\d+(/mod_sloodle/presenter/.*)#', $content, $matches)) {
  34. $content = '$@SITEROOT@$'.$matches[1].'$@CONTEXTID@$'.$matches[2];
  35. }
  36. return $content;
  37. }
  38. }