Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - https://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <https://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Defines backup_stickynotes_activity_task class.
19
 *
20
 * @package     mod_stickynotes
21
 * @copyright   2021 Olivier VALENTIN
22
 * @license     https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
require_once($CFG->dirroot.'/mod/stickynotes/backup/moodle2/backup_stickynotes_stepslib.php');
28
 
29
/**
30
 * Provides the steps to perform one complete backup of the stickynotes instance.
31
 */
32
class backup_stickynotes_activity_task extends backup_activity_task {
33
 
34
    /**
35
     * No specific settings for this activity.
36
     */
37
    protected function define_my_settings() {
38
    }
39
 
40
    /**
41
     * Defines a backup step to store the instance data in the stickynotes.xml file.
42
     */
43
    protected function define_my_steps() {
44
        $this->add_step(new backup_stickynotes_activity_structure_step('stickynotes_structure', 'stickynotes.xml'));
45
    }
46
 
47
    /**
48
     * Encodes URLs to the index.php and view.php scripts.
49
     *
50
     * @param string $content some HTML text that eventually contains URLs to the activity instance scripts.
51
     * @return string $content The content with the URLs encoded.
52
     */
53
    public static function encode_content_links($content) {
54
 
55
        global $CFG;
56
 
57
        $base = preg_quote($CFG->wwwroot.'/mod/stickynotes', '#');
58
 
59
        // Link to the list of stickynotess.
60
        $pattern = "#(".$base."\/index.php\?id\=)([0-9]+)#";
61
        $content = preg_replace($pattern, '$@STICKYNOTESINDEX*$2@$', $content);
62
 
63
        // Link to stickynotes view by moduleid.
64
        $pattern = "#(".$base."\/view.php\?id\=)([0-9]+)#";
65
        $content = preg_replace($pattern, '$@STICKYNOTESVIEWBYID*$2@$', $content);
66
 
67
        return $content;
68
    }
69
}