MDL-68483 contentbank: improve search API
[moodle.git] / contentbank / tests / fixtures / testable_contenttype.php
CommitLineData
70819075
AA
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 * Testable contenttype plugin class.
19 *
20 * @package core_contentbank
21 * @category test
22 * @copyright 2020 Sara Arjona <sara@moodle.com>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26namespace contenttype_testable;
27
28/**
29 * Testable contenttype plugin class.
30 *
31 * @package core_contentbank
32 * @copyright 2020 Sara Arjona <sara@moodle.com>
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 */
35class contenttype extends \core_contentbank\contenttype {
36
37 /** Feature for testing */
38 const CAN_TEST = 'test';
39
40 /**
41 * Returns the URL where the content will be visualized.
42 *
43 * @param stdClass $record Th content to be displayed.
44 * @return string URL where to visualize the given content.
45 */
46 public function get_view_url(\stdClass $record): string {
47 $fileurl = $this->get_file_url($record->id);
48 $url = $fileurl."?forcedownload=1";
49
50 return $url;
51 }
52
53 /**
54 * Returns the HTML code to render the icon for content bank contents.
55 *
56 * @param string $contentname The contentname to add as alt value to the icon.
57 * @return string HTML code to render the icon
58 */
59 public function get_icon(string $contentname): string {
60 global $OUTPUT;
61
62 return $OUTPUT->pix_icon('f/archive-64', $contentname, 'moodle', ['class' => 'iconsize-big']);
63 }
64
65 /**
66 * Return an array of implemented features by this plugin.
67 *
68 * @return array
69 */
70 protected function get_implemented_features(): array {
71 return [self::CAN_TEST];
72 }
73
74 /**
75 * Return an array of extensions this plugin could manage.
76 *
77 * @return array
78 */
79 public function get_manageable_extensions(): array {
80 return ['.txt', '.png', '.h5p'];
81 }
82}