Commit | Line | Data |
---|---|---|
842cd18b | 1 | <?php |
1502bf77 AD |
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/>. | |
842cd18b AD |
16 | |
17 | /** | |
18 | * Web service documentation renderer. | |
13d1c9ed JF |
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 | |
842cd18b AD |
23 | */ |
24 | ||
13d1c9ed JF |
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 | */ | |
842cd18b AD |
32 | class core_rss_renderer extends plugin_renderer_base { |
33 | /** | |
13d1c9ed | 34 | * Returns the html for the token reset confirmation box |
842cd18b AD |
35 | * @return string html |
36 | */ | |
37 | public function user_reset_rss_token_confirmation() { | |
1dcd0d34 | 38 | global $CFG; |
842cd18b | 39 | $managetokenurl = $CFG->wwwroot."/user/managetoken.php?sesskey=" . sesskey(); |
1502bf77 AD |
40 | $optionsyes = array('action' => 'resetrsstoken', 'confirm' => 1, 'sesskey' => sesskey()); |
41 | $optionsno = array('section' => 'webservicetokens', 'sesskey' => sesskey()); | |
842cd18b AD |
42 | $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset')); |
43 | $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno), get_string('cancel'), 'get'); | |
1dcd0d34 | 44 | $html = $this->output->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel); |
842cd18b AD |
45 | return $html; |
46 | } | |
47 | ||
48 | /** | |
13d1c9ed JF |
49 | * Display a user token with buttons to reset it |
50 | * @param string $token The token to be displayed | |
842cd18b AD |
51 | * @return string html code |
52 | */ | |
53 | public function user_rss_token_box($token) { | |
1dcd0d34 | 54 | global $CFG; |
842cd18b | 55 | |
1502bf77 | 56 | // Display strings. |
842cd18b AD |
57 | $stroperation = get_string('operation', 'webservice'); |
58 | $strtoken = get_string('key', 'webservice'); | |
59 | ||
1dcd0d34 TH |
60 | $return = $this->output->heading(get_string('rss', 'rss'), 3, 'main', true); |
61 | $return .= $this->output->box_start('generalbox webservicestokenui'); | |
842cd18b | 62 | |
636b4f9d | 63 | $return .= get_string('rsskeyshelp'); |
842cd18b AD |
64 | |
65 | $table = new html_table(); | |
66 | $table->head = array($strtoken, $stroperation); | |
67 | $table->align = array('left', 'center'); | |
68 | $table->width = '100%'; | |
69 | $table->data = array(); | |
70 | ||
71 | if (!empty($token)) { | |
72 | $reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey(). | |
73 | "&action=resetrsstoken\">".get_string('reset')."</a>"; | |
74 | ||
75 | $table->data[] = array($token, $reset); | |
76 | ||
77 | $return .= html_writer::table($table); | |
78 | } else { | |
79 | $return .= get_string('notoken', 'webservice'); | |
80 | } | |
81 | ||
1dcd0d34 | 82 | $return .= $this->output->box_end(); |
842cd18b AD |
83 | return $return; |
84 | } | |
636b4f9d | 85 | } |