Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Output rendering for the plugin.
19
 *
20
 * @package     tool_messageinbound
21
 * @copyright   2014 Andrew Nicols
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
/**
28
 * Implements the plugin renderer
29
 *
30
 * @copyright 2014 Andrew Nicols
31
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 */
33
class tool_messageinbound_renderer extends plugin_renderer_base {
34
 
35
    /**
36
     * Render a table listing all of the Inbound Message handlers.
37
     *
38
     * @param array $handlers - list of all messageinbound handlers.
39
     * @return string HTML to output.
40
     */
41
    public function messageinbound_handlers_table(array $handlers) {
42
        global $CFG;
43
 
44
        $table = new html_table();
45
        $handlername = new html_table_cell(get_string('name', 'tool_messageinbound') . "\n" .
46
                html_writer::tag('span', get_string('classname', 'tool_messageinbound'), array('class' => 'handler-function')));
47
 
48
        // Prepare some of the rows with additional styling.
49
        $enabled = new html_table_cell(get_string('enabled', 'tool_messageinbound'));
50
        $enabled->attributes['class'] = 'state';
51
        $edit = new html_table_cell(get_string('edit', 'tool_messageinbound'));
52
        $edit->attributes['class'] = 'edit';
53
        $table->head  = array(
54
                $handlername,
55
                get_string('description', 'tool_messageinbound'),
56
                $enabled,
57
                $edit,
58
            );
59
        $table->attributes['class'] = 'admintable generaltable messageinboundhandlers';
60
 
61
        $yes = get_string('yes');
62
        $no = get_string('no');
63
 
64
        $data = array();
65
 
66
        // Options for description formatting.
67
        $descriptionoptions = new stdClass();
68
        $descriptionoptions->trusted = false;
69
        $descriptionoptions->noclean = false;
70
        $descriptionoptions->filter = false;
71
        $descriptionoptions->para = true;
72
        $descriptionoptions->newlines = false;
73
        $descriptionoptions->overflowdiv = true;
74
 
75
        $editurlbase = new moodle_url('/admin/tool/messageinbound/index.php');
76
        foreach ($handlers as $handler) {
77
            $handlername = new html_table_cell($handler->name . "\n" .
78
                    html_writer::tag('span', $handler->classname, array('class' => 'handler-function')));
79
            $handlername->header = true;
80
 
81
            $editurl = new moodle_url($editurlbase, array('classname' => $handler->classname));
82
            $editlink = $this->action_icon($editurl, new pix_icon('t/edit',
83
                    get_string('edithandler', 'tool_messageinbound', $handler->classname)));
84
 
85
            // Prepare some of the rows with additional styling.
86
            $enabled = new html_table_cell($handler->enabled ? $yes : $no);
87
            $enabled->attributes['class'] = 'state';
88
            $edit = new html_table_cell($editlink);
89
            $edit->attributes['class'] = 'edit';
90
 
91
            // Add the row.
92
            $row = new html_table_row(array(
93
                        $handlername,
94
                        format_text($handler->description, FORMAT_MARKDOWN, $descriptionoptions),
95
                        $enabled,
96
                        $edit,
97
                    ));
98
 
99
            if (!$handler->enabled) {
100
                $row->attributes['class'] = 'disabled';
101
            }
102
            $data[] = $row;
103
        }
104
        $table->data = $data;
105
        return html_writer::table($table);
106
    }
107
 
108
}