See Release Notes
Long Term Support Release
Differences Between: [Versions 400 and 401] [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 /** 18 * Contains the default activity name inplace editable. 19 * 20 * @package core_courseformat 21 * @copyright 2020 Ferran Recio <ferran@moodle.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace core_courseformat\output\local\content\cm; 26 27 use cm_info; 28 use core\output\named_templatable; 29 use core_courseformat\base as course_format; 30 use core_courseformat\output\local\courseformat_named_templatable; 31 use renderable; 32 use section_info; 33 use stdClass; 34 35 /** 36 * Base class to render a course module inplace editable header. 37 * 38 * @package core_courseformat 39 * @copyright 2020 Ferran Recio <ferran@moodle.com> 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 */ 42 class cmname implements named_templatable, renderable { 43 44 use courseformat_named_templatable; 45 46 /** @var course_format the course format */ 47 protected $format; 48 49 /** @var section_info the section object */ 50 private $section; 51 52 /** @var cm_info the course module instance */ 53 protected $mod; 54 55 /** @var array optional display options */ 56 protected $displayoptions; 57 58 /** @var string the activity title output class name */ 59 protected $titleclass; 60 61 /** 62 * Constructor. 63 * 64 * @param course_format $format the course format 65 * @param section_info $section the section info 66 * @param cm_info $mod the course module ionfo 67 * @param null $unused This parameter has been deprecated since 4.1 and should not be used anymore. 68 * @param array $displayoptions optional extra display options 69 */ 70 public function __construct( 71 course_format $format, 72 section_info $section, 73 cm_info $mod, 74 ?bool $unused = null, 75 array $displayoptions = [] 76 ) { 77 if ($unused !== null) { 78 debugging('Deprecated argument passed to ' . __FUNCTION__, DEBUG_DEVELOPER); 79 } 80 81 $this->format = $format; 82 $this->section = $section; 83 $this->mod = $mod; 84 $this->displayoptions = $displayoptions; 85 86 // Get the necessary classes. 87 $this->titleclass = $format->get_output_classname('content\\cm\\title'); 88 } 89 90 /** 91 * Export this data so it can be used as the context for a mustache template. 92 * 93 * @param \renderer_base $output typically, the renderer that's calling this function 94 * @return stdClass data context for a mustache template 95 */ 96 public function export_for_template(\renderer_base $output): array { 97 $mod = $this->mod; 98 $displayoptions = $this->displayoptions; 99 100 if (!$this->has_name()) { 101 // Nothing to be displayed to the user. 102 return []; 103 } 104 105 $iconurl = $mod->get_icon_url(); 106 $iconclass = $iconurl->get_param('filtericon') ? '' : 'nofilter'; 107 $data = [ 108 'url' => $mod->url, 109 'icon' => $iconurl, 110 'iconclass' => $iconclass, 111 'modname' => $mod->modname, 112 'textclasses' => $displayoptions['textclasses'] ?? '', 113 'pluginname' => get_string('pluginname', 'mod_' . $mod->modname), 114 'showpluginname' => $this->format->show_editor(), 115 'purpose' => plugin_supports('mod', $mod->modname, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER), 116 'activityname' => $this->get_title_data($output), 117 ]; 118 119 return $data; 120 } 121 122 /** 123 * Get the title data. 124 * 125 * @param \renderer_base $output typically, the renderer that's calling this function 126 * @return array data context for a mustache template 127 */ 128 protected function get_title_data(\renderer_base $output): array { 129 $title = new $this->titleclass( 130 $this->format, 131 $this->section, 132 $this->mod, 133 $this->displayoptions 134 ); 135 return (array) $title->export_for_template($output); 136 } 137 138 /** 139 * Return if the activity has a visible name. 140 * 141 * @return bool if the title is visible. 142 */ 143 public function has_name(): bool { 144 return $this->mod->is_visible_on_course_page() && $this->mod->url; 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body