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 |
* Base class to make it easier to implement actions that are menuable_actions.
|
|
|
19 |
*
|
|
|
20 |
* @package core_question
|
|
|
21 |
* @copyright 2019 Tim Hunt
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace core_question\local\bank;
|
|
|
26 |
|
|
|
27 |
/**
|
|
|
28 |
* Base class to make it easier to implement actions that are menuable_actions.
|
|
|
29 |
*
|
|
|
30 |
* Use this class if your action is simple (defined by just a URL, label and icon).
|
|
|
31 |
* If your action is not simple enough to fit into the pattern that this
|
|
|
32 |
* class implements, then you will have to implement the menuable_action
|
|
|
33 |
* interface yourself.
|
|
|
34 |
*
|
|
|
35 |
* @copyright 2019 Tim Hunt
|
|
|
36 |
* @author 2021 Safat Shahin <safatshahin@catalyst-au.net>
|
|
|
37 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
38 |
* @deprecated Since Moodle 4.3 MDL-75125 - Use question_action_base instead.
|
|
|
39 |
* @todo MDL-78090 This class will be deleted in Moodle 4.7
|
|
|
40 |
*/
|
|
|
41 |
abstract class menu_action_column_base extends action_column_base implements menuable_action {
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
* Get the information required to display this action either as a menu item or a separate action column.
|
|
|
45 |
*
|
|
|
46 |
* If this action cannot apply to this question (e.g. because the user does not have
|
|
|
47 |
* permission, then return [null, null, null].
|
|
|
48 |
*
|
|
|
49 |
* @param \stdClass $question the row from the $question table, augmented with extra information.
|
|
|
50 |
* @return array with three elements.
|
|
|
51 |
* $url - the URL to perform the action.
|
|
|
52 |
* $icon - the icon for this action. E.g. 't/delete'.
|
|
|
53 |
* $label - text label to display in the UI (either in the menu, or as a tool-tip on the icon)
|
|
|
54 |
*/
|
|
|
55 |
abstract protected function get_url_icon_and_label(\stdClass $question);
|
|
|
56 |
|
|
|
57 |
protected function display_content($question, $rowclasses): void {
|
|
|
58 |
debugging('The menu_action_column_base class is deprecated. Please use question_action_base instead.', DEBUG_DEVELOPER);
|
|
|
59 |
[$url, $icon, $label] = $this->get_url_icon_and_label($question);
|
|
|
60 |
if ($url) {
|
|
|
61 |
$this->print_icon($icon, $label, $url);
|
|
|
62 |
}
|
|
|
63 |
}
|
|
|
64 |
|
|
|
65 |
public function get_action_menu_link(\stdClass $question): ?\action_menu_link {
|
|
|
66 |
debugging('The menu_action_column_base class is deprecated. Please use question_action_base instead.', DEBUG_DEVELOPER);
|
|
|
67 |
[$url, $icon, $label] = $this->get_url_icon_and_label($question);
|
|
|
68 |
if (!$url) {
|
|
|
69 |
return null;
|
|
|
70 |
}
|
|
|
71 |
return new \action_menu_link_secondary($url, new \pix_icon($icon, ''), $label);
|
|
|
72 |
}
|
|
|
73 |
}
|