weekly release 2.2dev
[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.
24 * @package rss
25 * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
26 * @author Andrew Davis
27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28 */
29
30class core_rss_renderer extends plugin_renderer_base {
31 /**
32 * Returns the html for the token reset confirmation box
33 * @param object $token to reset
34 * @return string html
35 */
36 public function user_reset_rss_token_confirmation() {
37 global $OUTPUT, $CFG;
38 $managetokenurl = $CFG->wwwroot."/user/managetoken.php?sesskey=" . sesskey();
39 $optionsyes = array('action'=>'resetrsstoken', 'confirm'=>1, 'sesskey'=>sesskey());
40 $optionsno = array('section'=>'webservicetokens', 'sesskey'=>sesskey());
41 $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset'));
42 $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno), get_string('cancel'), 'get');
43 $html = $OUTPUT->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel);
44 return $html;
45 }
46
47 /**
48 * Display user tokens with buttons to reset them
49 * @param object $tokens
50 * @param int $userid
51 * @return string html code
52 */
53 public function user_rss_token_box($token) {
54 global $OUTPUT, $CFG;
55
56 // display strings
57 $stroperation = get_string('operation', 'webservice');
58 $strtoken = get_string('key', 'webservice');
59
60 $return = $OUTPUT->heading(get_string('rss'), 3, 'main', true);
61 $return .= $OUTPUT->box_start('generalbox webservicestokenui');
62
63 //$return .= get_string('keyshelp', 'webservice');
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 "&amp;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
82 $return .= $OUTPUT->box_end();
83 return $return;
84 }
85}