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 - http://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 <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Defines backup_hvp_activity_task class
19
 *
20
 * @package     mod_hvp
21
 * @category    backup
22
 * @copyright   2016 Joubel AS <contact@joubel.com>
23
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
require_once($CFG->dirroot . '/mod/hvp/backup/moodle2/backup_hvp_stepslib.php');
29
 
30
/**
31
 * Provides the steps to perform one complete backup of a H5P instance
32
 *
33
 * @copyright   2018 Joubel AS <contact@joubel.com>
34
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
36
class backup_hvp_activity_task extends backup_activity_task {
37
 
38
    /**
39
     * No specific settings for this activity
40
     */
41
    protected function define_my_settings() {
42
    }
43
 
44
    /**
45
     * Defines a backup step to store the instance data in the hvp.xml file
46
     */
47
    protected function define_my_steps() {
48
        global $CFG;
49
 
50
        // Add hvp activity data and content files.
51
        $this->add_step(new backup_hvp_activity_structure_step('hvp_structure', 'hvp.xml'));
52
 
53
        // Allow user to override library backup.
54
        $backuplibraries = !(isset($CFG->mod_hvp_backup_libraries) && $CFG->mod_hvp_backup_libraries === '0');
55
 
56
        // Exclude hvp libraries step for local 'imports'.
57
        if ($backuplibraries && backup_controller_dbops::backup_includes_files($this->plan->get_backupid())) {
58
 
59
            // Note that this step will only run once per backup as it generates
60
            // a shared resource.
61
            $this->add_step(new backup_hvp_libraries_structure_step('hvp_libraries', 'hvp_libraries.xml'));
62
        }
63
    }
64
 
65
    /**
66
     * Encodes URLs to the index.php and view.php scripts
67
     *
68
     * @param string $content some HTML text that eventually contains URLs to the activity instance scripts
69
     * @return string the content with the URLs encoded
70
     */
71
    static public function encode_content_links($content) {
72
        global $CFG;
73
 
74
        $base = preg_quote($CFG->wwwroot, "/");
75
 
76
        // Link to the list of glossaries.
77
        $search = "/(".$base."\/mod\/hvp\/index.php\?id\=)([0-9]+)/";
78
        $content = preg_replace($search, '$@HVPINDEX*$2@$', $content);
79
 
80
        // Link to hvp view by module id.
81
        $search = "/(".$base."\/mod\/hvp\/view.php\?id\=)([0-9]+)/";
82
        $content = preg_replace($search, '$@HVPVIEWBYID*$2@$', $content);
83
 
84
        // Link to hvp embed by module id.
85
        $search = "/(".$base."\/mod\/hvp\/embed.php\?id\=)([0-9]+)/";
86
        $content = preg_replace($search, '$@HVPEMBEDBYID*$2@$', $content);
87
 
88
        return $content;
89
    }
90
}