MDL-37046 behat: Split in different classes
[moodle.git] / admin / tool / behat / renderer.php
CommitLineData
d46340eb
DM
1<?php
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/>.
16
17/**
18 * Behat tool renderer
19 *
20 * @package tool_behat
21 * @copyright 2012 David MonllaĆ³
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
a09534f4 25defined('MOODLE_INTERNAL') || die;
d46340eb
DM
26
27/**
28 * Renderer for behat tool web features
29 *
30 * @package tool_behat
31 * @copyright 2012 David MonllaĆ³
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 */
34class tool_behat_renderer extends plugin_renderer_base {
35
b5c13009
DM
36 /**
37 * @var string Docs url
38 */
39 protected $docsurl = 'http://docs.moodle.org/dev/Acceptance_testing';
40
d46340eb
DM
41 /**
42 * Renders the list of available steps according to the submitted filters
43 *
44 * @param string $stepsdefinitions HTML from behat with the available steps
45 * @param moodleform $form
46 * @return string HTML code
47 */
48 public function render_stepsdefinitions($stepsdefinitions, $form) {
49
50 $title = get_string('pluginname', 'tool_behat');
51
52 // Header.
53 $html = $this->output->header();
54 $html .= $this->output->heading($title);
55
56 // Info.
b5c13009 57 $installurl = $this->docsurl . '#Installation';
d46340eb 58 $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank'));
b5c13009 59 $writetestsurl = $this->docsurl . '#Writting_features';
d46340eb 60 $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank'));
b5c13009 61 $writestepsurl = $this->docsurl . '#Adding_steps_definitions';
d46340eb
DM
62 $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank'));
63 $infos = array(
95167121
DM
64 get_string('installinfo', 'tool_behat', $installlink),
65 get_string('newtestsinfo', 'tool_behat', $writetestslink),
66 get_string('newstepsinfo', 'tool_behat', $writestepslink)
d46340eb
DM
67 );
68 $html .= $this->output->box_start();
69 $html .= html_writer::tag('h1', 'Info');
70 $html .= html_writer::tag('div', '<ul><li>' . implode('</li><li>', $infos) . '</li></ul>');
71 $html .= $this->output->box_end();
72
73 // Form.
74 ob_start();
75 $form->display();
76 $html .= ob_get_contents();
77 ob_end_clean();
78
79 // Steps definitions.
80 $html .= html_writer::tag('div', $stepsdefinitions, array('id' => 'steps-definitions'));
81
82 $html .= $this->output->footer();
83
84 return $html;
85 }
86}