3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * Output rendering for the plugin.
21 * @package tool_installaddon
23 * @copyright 2013 David Mudrak <david@moodle.com>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 defined('MOODLE_INTERNAL') || die();
30 * Implements the plugin renderer
32 * @copyright 2013 David Mudrak <david@moodle.com>
33 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 class tool_installaddon_renderer extends plugin_renderer_base {
37 /** @var tool_installaddon_installer */
38 protected $installer = null;
41 * Sets the tool_installaddon_installer instance being used.
43 * @throws coding_exception if the installer has been already set
44 * @param tool_installaddon_installer $installer
46 public function set_installer_instance(tool_installaddon_installer $installer) {
47 if (is_null($this->installer)) {
48 $this->installer = $installer;
50 throw new coding_exception('Attempting to reset the installer instance.');
55 * Defines the index page layout
59 public function index_page() {
61 $out = $this->output->header();
62 $out .= $this->index_page_heading();
63 $out .= $this->index_page_repository();
64 $out .= $this->index_page_upload();
65 $out .= $this->output->footer();
71 * Renders the index page heading
75 protected function index_page_heading() {
76 return $this->output->heading(get_string('pluginname', 'tool_installaddon'));
80 * Renders the widget for browsing the add-on repository
84 protected function index_page_repository() {
86 $url = $this->installer->get_addons_repository_url();
89 $this->output->single_button($url, get_string('installfromrepo', 'tool_installaddon'), 'get').
90 $this->output->help_icon('installfromrepo', 'tool_installaddon'),
91 'generalbox', 'installfromrepobox'
98 * Renders the widget for uploading the add-on ZIP package
102 protected function index_page_upload() {
104 $form = $this->installer->get_installfromzip_form();
108 $out = ob_get_clean();
110 $out = $this->box($out, 'generalbox', 'installfromzipbox');