Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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 * Class containing data for list_templates page 19 * 20 * @package tool_templatelibrary 21 * @copyright 2015 Damyon Wiese 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 namespace tool_templatelibrary\output; 25 26 use renderable; 27 use templatable; 28 use renderer_base; 29 use stdClass; 30 use core_plugin_manager; 31 use tool_templatelibrary\api; 32 33 /** 34 * Class containing data for list_templates page 35 * 36 * @copyright 2015 Damyon Wiese 37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 38 */ 39 class list_templates_page implements renderable, templatable { 40 41 /** @var string $component The currently selected component */ 42 protected $component; 43 /** @var string $search The current search */ 44 protected $search; 45 46 /** 47 * Template page constructor 48 * 49 * @param string $component 50 * @param string $search 51 */ 52 public function __construct(string $component = '', string $search = '') { 53 $this->component = $component; 54 $this->search = $search; 55 } 56 57 /** 58 * Export this data so it can be used as the context for a mustache template. 59 * 60 * @return stdClass 61 */ 62 public function export_for_template(renderer_base $output) { 63 $data = new stdClass(); 64 $data->allcomponents = array(); 65 $data->search = $this->search; 66 $fulltemplatenames = api::list_templates(); 67 $pluginmanager = core_plugin_manager::instance(); 68 $components = array(); 69 70 foreach ($fulltemplatenames as $templatename) { 71 list($component, $templatename) = explode('/', $templatename, 2); 72 $components[$component] = 1; 73 } 74 75 $components = array_keys($components); 76 foreach ($components as $component) { 77 $info = new stdClass(); 78 $info->component = $component; 79 $info->selected = ($component === $this->component); 80 if (strpos($component, 'core') === 0) { 81 $info->name = get_string('coresubsystem', 'tool_templatelibrary', $component); 82 } else { 83 $info->name = $pluginmanager->plugin_name($component); 84 } 85 $data->allcomponents[] = $info; 86 } 87 88 return $data; 89 } 90 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body