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 |
* Tour Step Renderable.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_usertours
|
|
|
21 |
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace tool_usertours\output;
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
require_once($CFG->libdir . "/filelib.php");
|
|
|
30 |
|
|
|
31 |
use tool_usertours\helper;
|
|
|
32 |
use tool_usertours\step as stepsource;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Tour Step Renderable.
|
|
|
36 |
*
|
|
|
37 |
* @copyright 2016 Andrew Nicols <andrew@nicols.co.uk>
|
|
|
38 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
39 |
*/
|
|
|
40 |
class step implements \renderable {
|
|
|
41 |
/**
|
|
|
42 |
* @var The step instance.
|
|
|
43 |
*/
|
|
|
44 |
protected $step;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* The step output.
|
|
|
48 |
*
|
|
|
49 |
* @param stepsource $step The step being output.
|
|
|
50 |
*/
|
|
|
51 |
public function __construct(stepsource $step) {
|
|
|
52 |
$this->step = $step;
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* Export the step configuration.
|
|
|
57 |
*
|
|
|
58 |
* @param renderer_base $output The renderer.
|
|
|
59 |
* @return object
|
|
|
60 |
*/
|
|
|
61 |
public function export_for_template(\renderer_base $output) {
|
|
|
62 |
global $PAGE;
|
|
|
63 |
$step = $this->step;
|
|
|
64 |
|
|
|
65 |
$content = $step->get_content();
|
|
|
66 |
$systemcontext = \context_system::instance();
|
|
|
67 |
$content = file_rewrite_pluginfile_urls(
|
|
|
68 |
$content,
|
|
|
69 |
'pluginfile.php',
|
|
|
70 |
$systemcontext->id,
|
|
|
71 |
'tool_usertours',
|
|
|
72 |
'stepcontent',
|
|
|
73 |
$step->get_id()
|
|
|
74 |
);
|
|
|
75 |
|
|
|
76 |
$content = helper::get_string_from_input($content);
|
|
|
77 |
$content = $step::get_step_image_from_input($content);
|
|
|
78 |
|
|
|
79 |
$result = (object) [
|
|
|
80 |
'stepid' => $step->get_id(),
|
|
|
81 |
'title' => \core_external\util::format_text(
|
|
|
82 |
helper::get_string_from_input($step->get_title()),
|
|
|
83 |
FORMAT_HTML,
|
|
|
84 |
$PAGE->context->id,
|
|
|
85 |
'tool_usertours'
|
|
|
86 |
)[0],
|
|
|
87 |
'content' => \core_external\util::format_text(
|
|
|
88 |
$content,
|
|
|
89 |
$step->get_contentformat(),
|
|
|
90 |
$PAGE->context->id,
|
|
|
91 |
'tool_usertours'
|
|
|
92 |
)[0],
|
|
|
93 |
'element' => $step->get_target()->convert_to_css(),
|
|
|
94 |
];
|
|
|
95 |
|
|
|
96 |
foreach ($step->get_config_keys() as $key) {
|
|
|
97 |
$result->$key = $step->get_config($key);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
return $result;
|
|
|
101 |
}
|
|
|
102 |
}
|