weekly release 2.8dev
[moodle.git] / rss / renderer.php
CommitLineData
842cd18b
AD
1<?php
2///////////////////////////////////////////////////////////////////////////
3// //
4// This file is part of Moodle - http://moodle.org/ //
5// Moodle - Modular Object-Oriented Dynamic Learning Environment //
6// //
7// Moodle is free software: you can redistribute it and/or modify //
8// it under the terms of the GNU General Public License as published by //
9// the Free Software Foundation, either version 3 of the License, or //
10// (at your option) any later version. //
11// //
12// Moodle is distributed in the hope that it will be useful, //
13// but WITHOUT ANY WARRANTY; without even the implied warranty of //
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15// GNU General Public License for more details. //
16// //
17// You should have received a copy of the GNU General Public License //
18// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
19// //
20///////////////////////////////////////////////////////////////////////////
21
22/**
23 * Web service documentation renderer.
13d1c9ed
JF
24 * @package core_rss
25 * @category rss
26 * @copyright 2010 Andrew Davis
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
842cd18b
AD
28 */
29
13d1c9ed
JF
30/**
31 * Web service documentation renderer extending the plugin_renderer_base class.
32 * @package core_rss
33 * @category rss
34 * @copyright 2010 Andrew Davis
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 */
842cd18b
AD
37class core_rss_renderer extends plugin_renderer_base {
38 /**
13d1c9ed 39 * Returns the html for the token reset confirmation box
842cd18b
AD
40 * @return string html
41 */
42 public function user_reset_rss_token_confirmation() {
43 global $OUTPUT, $CFG;
44 $managetokenurl = $CFG->wwwroot."/user/managetoken.php?sesskey=" . sesskey();
45 $optionsyes = array('action'=>'resetrsstoken', 'confirm'=>1, 'sesskey'=>sesskey());
46 $optionsno = array('section'=>'webservicetokens', 'sesskey'=>sesskey());
47 $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset'));
48 $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno), get_string('cancel'), 'get');
49 $html = $OUTPUT->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel);
50 return $html;
51 }
52
53 /**
13d1c9ed
JF
54 * Display a user token with buttons to reset it
55 * @param string $token The token to be displayed
842cd18b
AD
56 * @return string html code
57 */
58 public function user_rss_token_box($token) {
59 global $OUTPUT, $CFG;
60
61 // display strings
62 $stroperation = get_string('operation', 'webservice');
63 $strtoken = get_string('key', 'webservice');
64
65 $return = $OUTPUT->heading(get_string('rss'), 3, 'main', true);
66 $return .= $OUTPUT->box_start('generalbox webservicestokenui');
67
636b4f9d 68 $return .= get_string('rsskeyshelp');
842cd18b
AD
69
70 $table = new html_table();
71 $table->head = array($strtoken, $stroperation);
72 $table->align = array('left', 'center');
73 $table->width = '100%';
74 $table->data = array();
75
76 if (!empty($token)) {
77 $reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey().
78 "&amp;action=resetrsstoken\">".get_string('reset')."</a>";
79
80 $table->data[] = array($token, $reset);
81
82 $return .= html_writer::table($table);
83 } else {
84 $return .= get_string('notoken', 'webservice');
85 }
86
87 $return .= $OUTPUT->box_end();
88 return $return;
89 }
636b4f9d 90}