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_course\output\actionbar;
|
|
|
18 |
|
|
|
19 |
use core\output\renderable;
|
|
|
20 |
use core\output\renderer_base;
|
|
|
21 |
use stdClass;
|
|
|
22 |
use templatable;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* Renderable class for the initial_dropdown_form.
|
|
|
26 |
*
|
|
|
27 |
* This form is the content for the initials_selector renderable, which itself is an extension of the comboboxsearch component.
|
|
|
28 |
* {@see initials_selector}.
|
|
|
29 |
*
|
|
|
30 |
* @package core_course
|
|
|
31 |
* @copyright 2024 Jake Dallimore <jrhdallimore@gmail.com>
|
|
|
32 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
33 |
*/
|
|
|
34 |
class initials_dropdown_form implements renderable, templatable {
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* The class constructor.
|
|
|
38 |
*
|
|
|
39 |
* @param stdClass $course The course object.
|
|
|
40 |
* @param string $targeturl The target URL to send the form to.
|
|
|
41 |
* @param string $firstinitial The selected first initial.
|
|
|
42 |
* @param string $lastinitial The selected last initial.
|
|
|
43 |
* @param string $firstinitialparam The parameter name for the first initial.
|
|
|
44 |
* @param string $lastinitialparam The parameter name for the last initial.
|
|
|
45 |
* @param array $additionalparams Any additional parameters required for the form submission URL.
|
|
|
46 |
*/
|
|
|
47 |
public function __construct(
|
|
|
48 |
protected stdClass $course,
|
|
|
49 |
protected string $targeturl,
|
|
|
50 |
protected string $firstinitial = '',
|
|
|
51 |
protected string $lastinitial = '',
|
|
|
52 |
protected string $firstinitialparam = 'sifirst',
|
|
|
53 |
protected string $lastinitialparam = 'silast',
|
|
|
54 |
protected array $additionalparams = []
|
|
|
55 |
) {
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public function export_for_template(renderer_base $output) {
|
|
|
59 |
global $PAGE;
|
|
|
60 |
|
|
|
61 |
$PAGE->requires->js_call_amd('core_course/actionbar/initials', 'init',
|
|
|
62 |
[$this->targeturl, $this->firstinitialparam, $this->lastinitialparam, $this->additionalparams]);
|
|
|
63 |
$renderer = $PAGE->get_renderer('core_user');
|
|
|
64 |
|
|
|
65 |
return (object) [
|
|
|
66 |
'courseid' => $this->course->id,
|
|
|
67 |
'initialsbars' => $renderer->partial_user_search($this->targeturl, $this->firstinitial, $this->lastinitial, true),
|
|
|
68 |
];
|
|
|
69 |
}
|
|
|
70 |
}
|