2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Loglive report renderer.
20 * @package report_loglive
21 * @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 defined('MOODLE_INTERNAL') ||
die;
27 * Report log renderer's for printing reports.
30 * @package report_loglive
31 * @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34 class report_loglive_renderer
extends plugin_renderer_base
{
37 * This method should never be manually called, it should only be called by process.
38 * Please call the render method instead.
40 * @deprecated since 2.8, to be removed in 2.9
41 * @param report_loglive_renderable $reportloglive
44 public function render_report_loglive_renderable(report_loglive_renderable
$reportloglive) {
45 debugging('Do not call this method. Please call $renderer->render($reportloglive) instead.', DEBUG_DEVELOPER
);
46 return $this->render($reportloglive);
50 * Return html to render the loglive page..
52 * @param report_loglive_renderable $reportloglive object of report_log.
54 * @return string html used to render the page;
56 protected function render_report_loglive(report_loglive_renderable
$reportloglive) {
57 if (empty($reportloglive->selectedlogreader
)) {
58 return $this->output
->notification(get_string('nologreaderenabled', 'report_loglive'), 'notifyproblem');
61 $table = $reportloglive->get_table();
62 return $this->render_table($table, $reportloglive->perpage
);
66 * Prints/return reader selector
68 * @param report_loglive_renderable $reportloglive log report.
70 * @return string Returns rendered widget
72 public function reader_selector(report_loglive_renderable
$reportloglive) {
73 $readers = $reportloglive->get_readers(true);
74 if (count($readers) <= 1) {
75 // One or no readers found, no need of this drop down.
78 $select = new single_select($reportloglive->url
, 'logreader', $readers, $reportloglive->selectedlogreader
, null);
79 $select->set_label(get_string('selectlogreader', 'report_loglive'));
80 return $this->output
->render($select);
84 * Prints a button to update/resume live updates.
86 * @param report_loglive_renderable $reportloglive log report.
88 * @return string Returns rendered widget
90 public function toggle_liveupdate_button(report_loglive_renderable
$reportloglive) {
91 // Add live log controls.
92 if ($reportloglive->page
== 0 && $reportloglive->selectedlogreader
) {
93 echo html_writer
::tag('button' , get_string('pause', 'report_loglive'),
94 array('id' => 'livelogs-pause-button', 'class' => 'btn btn-secondary'));
95 $icon = new pix_icon('i/loading_small', 'loading', 'moodle', array('class' => 'spinner'));
96 return html_writer
::tag('span', $this->output
->render($icon), array('class' => 'spinner'));
102 * Get the html for the table.
104 * @param report_loglive_table_log $table table object.
105 * @param int $perpage entries to display perpage.
107 * @return string table html
109 protected function render_table(report_loglive_table_log
$table, $perpage) {
112 $table->out($perpage, true);
113 $o = ob_get_contents();