See Release Notes
Long Term Support Release
Differences Between: [Versions 401 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 namespace core\output; 18 19 use context; 20 use renderable; 21 use stdClass; 22 use templatable; 23 24 /** 25 * The filter renderable class. 26 * 27 * @package core 28 * @copyright 2021 Catalyst IT Australia Pty Ltd 29 * @author Tomo Tsuyuki <tomotsuyuki@catalyst-au.net> 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 abstract class datafilter implements renderable, templatable { 33 34 /** @var context $context The context where the filters are being rendered. */ 35 protected $context; 36 37 /** @var string $tableregionid Container of the table to be updated by this filter, is used to retrieve the table */ 38 protected $tableregionid; 39 40 /** @var stdClass $course The course shown */ 41 protected $course; 42 43 /** 44 * Filter constructor. 45 * 46 * @param context $context The context where the filters are being rendered 47 * @param string|null $tableregionid Container of the table which will be updated by this filter 48 */ 49 public function __construct(context $context, ?string $tableregionid = null) { 50 $this->context = $context; 51 $this->tableregionid = $tableregionid; 52 53 if ($context instanceof \context_course) { 54 $this->course = get_course($context->instanceid); 55 } 56 } 57 58 /** 59 * Get data for all filter types. 60 * 61 * @return array 62 */ 63 abstract protected function get_filtertypes(): array; 64 65 /** 66 * Get a standardised filter object. 67 * 68 * @param string $name 69 * @param string $title 70 * @param bool $custom 71 * @param bool $multiple 72 * @param string|null $filterclass 73 * @param array $values 74 * @param bool $allowempty 75 * @return stdClass|null 76 */ 77 protected function get_filter_object( 78 string $name, 79 string $title, 80 bool $custom, 81 bool $multiple, 82 ?string $filterclass, 83 array $values, 84 bool $allowempty = false 85 ): ?stdClass { 86 87 if (!$allowempty && empty($values)) { 88 // Do not show empty filters. 89 return null; 90 } 91 92 return (object) [ 93 'name' => $name, 94 'title' => $title, 95 'allowcustom' => $custom, 96 'allowmultiple' => $multiple, 97 'filtertypeclass' => $filterclass, 98 'values' => $values, 99 ]; 100 } 101 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body