Merge branch 'MD-31803' of git://github.com/mouneyrac/moodle
[moodle.git] / admin / registration / renderer.php
CommitLineData
07ab0c80 1<?php
f57c4047 2
07ab0c80 3///////////////////////////////////////////////////////////////////////////
4// //
5// This file is part of Moodle - http://moodle.org/ //
6// Moodle - Modular Object-Oriented Dynamic Learning Environment //
7// //
8// Moodle is free software: you can redistribute it and/or modify //
9// it under the terms of the GNU General Public License as published by //
10// the Free Software Foundation, either version 3 of the License, or //
11// (at your option) any later version. //
12// //
13// Moodle is distributed in the hope that it will be useful, //
14// but WITHOUT ANY WARRANTY; without even the implied warranty of //
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
16// GNU General Public License for more details. //
17// //
18// You should have received a copy of the GNU General Public License //
19// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
20// //
21///////////////////////////////////////////////////////////////////////////
22
07ab0c80 23/**
24 * Registration renderer.
25 * @package moodle
26 * @subpackage registration
27 * @copyright 2010 Moodle Pty Ltd (http://moodle.com)
28 * @author Jerome Mouneyrac
29 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30 */
31class core_register_renderer extends plugin_renderer_base {
32
b3245b75
DP
33 /**
34 * Display Moodle.org registration message about benefit to register on Moodle.org
35 *
36 * @return string
37 */
38 public function moodleorg_registration_message() {
39 $moodleorgurl = html_writer::link('http://moodle.org', 'Moodle.org');
40 $moodleorgstatsurl = html_writer::link('http://moodle.org/stats', get_string('statsmoodleorg', 'admin'));
41 $moochurl = html_writer::link(HUB_MOODLEORGHUBURL, 'MOOCH');
42 $moodleorgregmsg = get_string('registermoodleorg', 'admin', $moodleorgurl);
43 $items = array(get_string('registermoodleorgli1', 'admin'),
44 get_string('registermoodleorgli2', 'admin', $moodleorgstatsurl),
45 get_string('registermoodleorgli3', 'admin', $moochurl));
46 $moodleorgregmsg .= html_writer::alist($items);
47 return $moodleorgregmsg;
48 }
49
07ab0c80 50 /**
51 * Display a box message confirming a site registration (add or update)
52 * @param string $confirmationmessage
53 * @return string
54 */
55 public function registration_confirmation($confirmationmessage) {
c1466520 56 $linktositelist = html_writer::tag('a', get_string('sitelist', 'hub'),
57 array('href' => new moodle_url('/local/hub/index.php')));
f57c4047 58 $message = $confirmationmessage . html_writer::empty_tag('br') . $linktositelist;
c1466520 59 return $this->output->box($message);
07ab0c80 60 }
61
f57c4047 62 /**
63 * Display the listing of registered on hub
64 */
65 public function registeredonhublisting($hubs) {
a8e174cc 66 global $CFG;
f57c4047 67 $table = new html_table();
68 $table->head = array(get_string('hub', 'hub'), get_string('operation', 'hub'));
69 $table->size = array('80%', '20%');
70
71 foreach ($hubs as $hub) {
29ca816c 72 if ($hub->huburl == HUB_MOODLEORGHUBURL) {
73 $hub->hubname = get_string('registeredmoodleorg', 'hub', $hub->hubname);
74 }
f57c4047 75 $hublink = html_writer::tag('a', $hub->hubname, array('href' => $hub->huburl));
76 $hublinkcell = html_writer::tag('div', $hublink, array('class' => 'registeredhubrow'));
07ab0c80 77
a8e174cc 78 $unregisterhuburl = new moodle_url("/" . $CFG->admin . "/registration/index.php",
c1466520 79 array('sesskey' => sesskey(), 'huburl' => $hub->huburl,
80 'unregistration' => 1));
f57c4047 81 $unregisterbutton = new single_button($unregisterhuburl,
82 get_string('unregister', 'hub'));
83 $unregisterbutton->class = 'centeredbutton';
c1466520 84 $unregisterbuttonhtml = $this->output->render($unregisterbutton);
f57c4047 85
86 //add button cells
87 $cells = array($hublinkcell, $unregisterbuttonhtml);
88 $row = new html_table_row($cells);
89 $table->data[] = $row;
90 }
91
92 return html_writer::table($table);
07ab0c80 93 }
94
95}