1441 |
ariadna |
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 |
namespace core_contentbank\output;
|
|
|
18 |
|
|
|
19 |
use renderable;
|
|
|
20 |
use templatable;
|
|
|
21 |
use renderer_base;
|
|
|
22 |
use core_contentbank\content;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Content bank Custom fields renderable class.
|
|
|
26 |
*
|
|
|
27 |
* @package core_contentbank
|
|
|
28 |
* @copyright 2024 Daniel Neis Araujo <daniel@adapta.online>
|
|
|
29 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
30 |
*/
|
|
|
31 |
class customfields implements renderable, templatable {
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Constructor.
|
|
|
35 |
*
|
|
|
36 |
* @param \core_contentbank\content $content The content object.
|
|
|
37 |
*/
|
|
|
38 |
public function __construct(content $content) {
|
|
|
39 |
$this->content = $content;
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
/**
|
|
|
43 |
* Export the data.
|
|
|
44 |
*
|
|
|
45 |
* @param renderer_base $output
|
|
|
46 |
* @return stdClass
|
|
|
47 |
*/
|
|
|
48 |
public function export_for_template(renderer_base $output) {
|
|
|
49 |
global $DB;
|
|
|
50 |
|
|
|
51 |
$context = new \stdClass();
|
|
|
52 |
|
|
|
53 |
$context->url = $this->content->get_file_url();
|
|
|
54 |
$context->name = $this->content->get_name();
|
|
|
55 |
|
|
|
56 |
$handler = \core_contentbank\customfield\content_handler::create();
|
|
|
57 |
$customfields = $handler->get_instance_data($this->content->get_id());
|
|
|
58 |
$context->data = $handler->display_custom_fields_data($customfields);
|
|
|
59 |
|
|
|
60 |
return $context;
|
|
|
61 |
}
|
|
|
62 |
}
|