Differences Between: [Versions 400 and 403]
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 */ 39 abstract class menu_action_column_base extends action_column_base implements menuable_action { 40 41 /** 42 * Get the information required to display this action either as a menu item or a separate action column. 43 * 44 * If this action cannot apply to this question (e.g. because the user does not have 45 * permission, then return [null, null, null]. 46 * 47 * @param \stdClass $question the row from the $question table, augmented with extra information. 48 * @return array with three elements. 49 * $url - the URL to perform the action. 50 * $icon - the icon for this action. E.g. 't/delete'. 51 * $label - text label to display in the UI (either in the menu, or as a tool-tip on the icon) 52 */ 53 abstract protected function get_url_icon_and_label(\stdClass $question); 54 55 protected function display_content($question, $rowclasses): void { 56 [$url, $icon, $label] = $this->get_url_icon_and_label($question); 57 if ($url) { 58 $this->print_icon($icon, $label, $url); 59 } 60 } 61 62 public function get_action_menu_link(\stdClass $question): ?\action_menu_link { 63 [$url, $icon, $label] = $this->get_url_icon_and_label($question); 64 if (!$url) { 65 return null; 66 } 67 return new \action_menu_link_secondary($url, new \pix_icon($icon, ''), $label); 68 } 69 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body