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
 * Web service documentation renderer.
19
 * @package    core_rss
20
 * @category   rss
21
 * @copyright  2010 Andrew Davis
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/**
26
 * Web service documentation renderer extending the plugin_renderer_base class.
27
 * @package    core_rss
28
 * @category   rss
29
 * @copyright  2010 Andrew Davis
30
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
32
class core_rss_renderer extends plugin_renderer_base {
33
    /**
34
     * Returns the html for the token reset confirmation box
35
     * @return string html
36
     */
37
    public function user_reset_rss_token_confirmation() {
38
        $managetokenurl = '/user/managetoken.php';
39
        $optionsyes = ['action' => 'resetrsstoken', 'confirm' => 1];
40
        $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset'));
41
        $formcancel = new single_button(new moodle_url($managetokenurl), get_string('cancel'), 'get');
42
        $html = $this->output->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel);
43
        return $html;
44
    }
45
 
46
    /**
47
     * Display a user token with buttons to reset it
48
     * @param string $token The token to be displayed
49
     * @return string html code
50
     */
51
    public function user_rss_token_box($token) {
52
        global $CFG;
53
 
54
        // Display strings.
55
        $stroperation = get_string('operation', 'webservice');
56
        $strtoken = get_string('key', 'webservice');
57
 
58
        $return = $this->output->heading(get_string('rss', 'rss'), 3, 'main', true);
59
        $return .= $this->output->box_start('generalbox webservicestokenui');
60
 
61
        $return .= get_string('rsskeyshelp');
62
 
63
        $table = new html_table();
64
        $table->head  = array($strtoken, $stroperation);
65
        $table->align = array('left', 'center');
66
        $table->width = '100%';
67
        $table->data  = array();
68
 
69
        if (!empty($token)) {
70
            $reset = html_writer::link(new moodle_url('/user/managetoken.php', [
71
                'action' => 'resetrsstoken',
72
            ]), get_string('reset'));
73
 
74
            $table->data[] = array($token, $reset);
75
 
76
            $return .= html_writer::table($table);
77
        } else {
78
            $return .= get_string('notoken', 'webservice');
79
        }
80
 
81
        $return .= $this->output->box_end();
82
        return $return;
83
    }
84
}