MDL-22151 backup - folder implemented
[moodle.git] / mod / folder / backup / moodle2 / backup_folder_activity_task.class.php
CommitLineData
78692f23
EL
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18/**
19 * @package moodlecore
20 * @subpackage backup-moodle2
21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25require_once($CFG->dirroot . '/mod/folder/backup/moodle2/backup_folder_stepslib.php'); // Because it exists (must)
26
27/**
28 * folder backup task that provides all the settings and steps to perform one
29 * complete backup of the activity
30 */
31class backup_folder_activity_task extends backup_activity_task {
32
33 /**
34 * Define (add) particular settings this activity can have
35 */
36 protected function define_my_settings() {
37 // No particular settings for this activity
38 }
39
40 /**
41 * Define (add) particular steps this activity can have
42 */
43 protected function define_my_steps() {
44 // Choice only has one structure step
45 $this->add_step(new backup_folder_activity_structure_step('folder_structure', 'folder.xml'));
46 }
47
48 /**
49 * Code the transformations to perform in the activity in
50 * order to get transportable (encoded) links
51 */
52 static public function encode_content_links($content) {
53 global $CFG;
54
55 $base = preg_quote($CFG->wwwroot,"/");
56
57 // Link to the list of folder
58 $search="/(".$base."\/mod\/folder\/index.php\?id\=)([0-9]+)/";
59 $content= preg_replace($search, '$@FOLDERINDEX*$2@$', $content);
60
61 // Link to choice view by moduleid
62 $search="/(".$base."\/mod\/folder\/view.php\?id\=)([0-9]+)/";
63 $content= preg_replace($search, '$@FOLDERVIEWBYID*$2@$', $content);
64
65 return $content;
66 }
67}