Commit | Line | Data |
---|---|---|
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 | ||
096858ed DM |
25 | defined('MOODLE_INTERNAL') || die(); |
26 | ||
27 | global $CFG; | |
28 | require_once($CFG->libdir . '/behat/classes/behat_command.php'); | |
d46340eb DM |
29 | |
30 | /** | |
31 | * Renderer for behat tool web features | |
32 | * | |
33 | * @package tool_behat | |
34 | * @copyright 2012 David Monllaó | |
35 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
36 | */ | |
37 | class tool_behat_renderer extends plugin_renderer_base { | |
38 | ||
39 | /** | |
40 | * Renders the list of available steps according to the submitted filters | |
41 | * | |
42 | * @param string $stepsdefinitions HTML from behat with the available steps | |
43 | * @param moodleform $form | |
44 | * @return string HTML code | |
45 | */ | |
46 | public function render_stepsdefinitions($stepsdefinitions, $form) { | |
47 | ||
48 | $title = get_string('pluginname', 'tool_behat'); | |
49 | ||
50 | // Header. | |
51 | $html = $this->output->header(); | |
52 | $html .= $this->output->heading($title); | |
53 | ||
54 | // Info. | |
096858ed | 55 | $installurl = behat_command::DOCS_URL . '#Installation'; |
d46340eb | 56 | $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank')); |
096858ed | 57 | $writetestsurl = behat_command::DOCS_URL . '#Writting_features'; |
d46340eb | 58 | $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank')); |
096858ed | 59 | $writestepsurl = behat_command::DOCS_URL . '#Adding_steps_definitions'; |
d46340eb DM |
60 | $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank')); |
61 | $infos = array( | |
95167121 DM |
62 | get_string('installinfo', 'tool_behat', $installlink), |
63 | get_string('newtestsinfo', 'tool_behat', $writetestslink), | |
64 | get_string('newstepsinfo', 'tool_behat', $writestepslink) | |
d46340eb | 65 | ); |
096858ed DM |
66 | |
67 | // List of steps | |
d46340eb DM |
68 | $html .= $this->output->box_start(); |
69 | $html .= html_writer::tag('h1', 'Info'); | |
096858ed DM |
70 | $html .= html_writer::empty_tag('div'); |
71 | $html .= html_writer::empty_tag('ul'); | |
72 | $html .= html_writer::empty_tag('li'); | |
73 | $html .= implode(html_writer::end_tag('li') . html_writer::empty_tag('li'), $infos); | |
74 | $html .= html_writer::end_tag('li'); | |
75 | $html .= html_writer::end_tag('ul'); | |
76 | $html .= html_writer::end_tag('div'); | |
d46340eb DM |
77 | $html .= $this->output->box_end(); |
78 | ||
79 | // Form. | |
80 | ob_start(); | |
81 | $form->display(); | |
82 | $html .= ob_get_contents(); | |
83 | ob_end_clean(); | |
84 | ||
85 | // Steps definitions. | |
096858ed | 86 | $html .= html_writer::tag('div', $stepsdefinitions, array('class' => 'steps-definitions')); |
d46340eb DM |
87 | |
88 | $html .= $this->output->footer(); | |
89 | ||
90 | return $html; | |
91 | } | |
92 | } |