See Release Notes
Long Term Support Release
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 * Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page. 19 * 20 * @deprecated since Moodle 3.9 MDL-68612 - Please use \core_user\table\participants_search::class and table filtersets instead. 21 * @package core_user 22 * @copyright 2017 Jun Pataleta 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 namespace core_user\output; 26 27 use moodle_url; 28 use renderable; 29 use renderer_base; 30 use stdClass; 31 use templatable; 32 33 defined('MOODLE_INTERNAL') || die(); 34 35 /** 36 * Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page. 37 * 38 * @deprecated since Moodle 3.9 MDL-68612 - Please use \core_user\table\participants_search::class and table filtersets instead. 39 * @copyright 2017 Jun Pataleta 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 * 42 */ 43 class unified_filter implements renderable, templatable { 44 45 /** @var array $filteroptions The filter options. */ 46 protected $filteroptions; 47 48 /** @var array $selectedoptions The list of selected filter option values. */ 49 protected $selectedoptions; 50 51 /** @var moodle_url|string $baseurl The url with params needed to call up this page. */ 52 protected $baseurl; 53 54 /** 55 * unified_filter constructor. 56 * 57 * @param array $filteroptions The filter options. 58 * @param array $selectedoptions The list of selected filter option values. 59 * @param string|moodle_url $baseurl The url with params needed to call up this page. 60 */ 61 public function __construct($filteroptions, $selectedoptions, $baseurl = null) { 62 $deprecatedtext = __CLASS__ . ' class is deprecated. Please use \core\table\participants_search::class' . 63 ' with table filtersets instead.'; 64 debugging($deprecatedtext, DEBUG_DEVELOPER); 65 66 $this->filteroptions = $filteroptions; 67 $this->selectedoptions = $selectedoptions; 68 if (!empty($baseurl)) { 69 $this->baseurl = new moodle_url($baseurl); 70 } 71 } 72 73 /** 74 * Function to export the renderer data in a format that is suitable for a mustache template. 75 * 76 * @param renderer_base $output Used to do a final render of any components that need to be rendered for export. 77 * @return stdClass|array 78 */ 79 public function export_for_template(renderer_base $output) { 80 global $PAGE; 81 $data = new stdClass(); 82 if (empty($this->baseurl)) { 83 $this->baseurl = $PAGE->url; 84 } 85 $data->action = $this->baseurl->out(false); 86 87 foreach ($this->selectedoptions as $option) { 88 if (!isset($this->filteroptions[$option])) { 89 $this->filteroptions[$option] = $option; 90 } 91 } 92 93 $data->filteroptions = []; 94 $originalfilteroptions = []; 95 foreach ($this->filteroptions as $value => $label) { 96 $selected = in_array($value, $this->selectedoptions); 97 $filteroption = (object)[ 98 'value' => $value, 99 'label' => $label 100 ]; 101 $originalfilteroptions[] = $filteroption; 102 $filteroption->selected = $selected; 103 $data->filteroptions[] = $filteroption; 104 } 105 $data->originaloptionsjson = json_encode($originalfilteroptions); 106 return $data; 107 } 108 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body