See Release Notes
Long Term Support Release
Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]
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 * Contains class core_h5p\output\libraries 19 * 20 * @package core_h5p 21 * @copyright 2020 Ferran Recio 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_h5p\output; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use renderable; 30 use templatable; 31 use renderer_base; 32 use stdClass; 33 use moodle_url; 34 use action_menu; 35 use action_menu_link; 36 use pix_icon; 37 38 /** 39 * Class to help display H5P library management table. 40 * 41 * @copyright 2020 Ferran Recio 42 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 43 */ 44 class libraries implements renderable, templatable { 45 46 /** @var H5P factory */ 47 protected $factory; 48 49 /** @var H5P library list */ 50 protected $libraries; 51 52 /** 53 * Constructor. 54 * 55 * @param factory $factory The H5P factory 56 * @param array $libraries array of h5p libraries records 57 */ 58 public function __construct(\core_h5p\factory $factory, array $libraries) { 59 $this->factory = $factory; 60 $this->libraries = $libraries; 61 } 62 63 /** 64 * Export this data so it can be used as the context for a mustache template. 65 * 66 * @param renderer_base $output 67 * @return stdClass 68 */ 69 public function export_for_template(renderer_base $output) { 70 $installed = []; 71 $filestorage = $this->factory->get_core()->fs; 72 foreach ($this->libraries as $libraryname => $versions) { 73 foreach ($versions as $version) { 74 // Get the icon URL. 75 $version->icon = $filestorage->get_icon_url( 76 $version->id, 77 $version->machine_name, 78 $version->major_version, 79 $version->minor_version 80 ); 81 // Get the action menu options. 82 $actionmenu = new action_menu(); 83 $actionmenu->set_menu_trigger(get_string('actions', 'core_h5p')); 84 $actionmenu->prioritise = true; 85 $actionmenu->add_primary_action(new action_menu_link( 86 new moodle_url('/h5p/libraries.php', ['deletelibrary' => $version->id]), 87 new pix_icon('t/delete', get_string('deletelibraryversion', 'core_h5p')), 88 get_string('deletelibraryversion', 'core_h5p') 89 )); 90 $version->actionmenu = $actionmenu->export_for_template($output); 91 if ($version->enabled) { 92 $version->toggleenabledurl = new moodle_url('/h5p/libraries.php', [ 93 'id' => $version->id, 94 'action' => 'disable', 95 'sesskey' => sesskey(), 96 ]); 97 } else { 98 $version->toggleenabledurl = new moodle_url('/h5p/libraries.php', [ 99 'id' => $version->id, 100 'action' => 'enable', 101 'sesskey' => sesskey(), 102 ]); 103 } 104 $installed[] = $version; 105 } 106 } 107 $r = new stdClass(); 108 $r->contenttypes = $installed; 109 return $r; 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body