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 * Renderer class for manage rules page. 19 * 20 * @package tool_monitor 21 * @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace tool_monitor\output\managerules; 26 27 defined('MOODLE_INTERNAL') || die; 28 29 /** 30 * Renderer class for manage rules page. 31 * 32 * @since Moodle 2.8 33 * @package tool_monitor 34 * @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com> 35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 36 */ 37 class renderer extends \plugin_renderer_base { 38 39 /** 40 * Get html to display on the page. 41 * 42 * @param renderable $renderable renderable widget 43 * 44 * @return string to display on the mangerules page. 45 */ 46 protected function render_renderable(renderable $renderable) { 47 $o = $this->render_table($renderable); 48 $o .= $this->render_add_button($renderable->courseid); 49 50 return $o; 51 } 52 53 /** 54 * Get html to display on the page. 55 * 56 * @param renderable $renderable renderable widget 57 * 58 * @return string to display on the mangerules page. 59 */ 60 protected function render_table(renderable $renderable) { 61 $o = ''; 62 ob_start(); 63 $renderable->out($renderable->pagesize, true); 64 $o = ob_get_contents(); 65 ob_end_clean(); 66 67 return $o; 68 } 69 70 /** 71 * Html to add a button for adding a new rule. 72 * 73 * @param int $courseid course id. 74 * 75 * @return string html for the button. 76 */ 77 protected function render_add_button($courseid) { 78 global $CFG; 79 80 $button = \html_writer::tag('button', get_string('addrule', 'tool_monitor'), ['class' => 'btn btn-primary']); 81 $addurl = new \moodle_url($CFG->wwwroot. '/admin/tool/monitor/edit.php', array('courseid' => $courseid)); 82 return \html_writer::link($addurl, $button); 83 } 84 85 /** 86 * Html to add a link to go to the subscription page. 87 * 88 * @param moodle_url $manageurl The url of the subscription page. 89 * 90 * @return string html for the link to the subscription page. 91 */ 92 public function render_subscriptions_link($manageurl) { 93 echo \html_writer::start_div(); 94 $a = \html_writer::link($manageurl, get_string('managesubscriptions', 'tool_monitor')); 95 $link = \html_writer::tag('span', get_string('managesubscriptionslink', 'tool_monitor', $a)); 96 echo $link; 97 echo \html_writer::end_div(); 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body