MDL-40759 icons: Fix icons in action menus and links
[moodle.git] / grade / grading / renderer.php
CommitLineData
6832a102 1<?php
6832a102
DM
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 * Renderer for core_grading subsystem
19 *
d22e9e32 20 * @package core_grading
6832a102
DM
21 * @copyright 2011 David Mudrak <david@moodle.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 */
24
25defined('MOODLE_INTERNAL') || die();
26
27/**
28 * Standard HTML output renderer for core_grading subsystem
d22e9e32 29 *
5dc1ca87 30 * @package core_grading
d22e9e32
MG
31 * @copyright 2011 David Mudrak <david@moodle.com>
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 * @category grading
6832a102
DM
34 */
35class core_grading_renderer extends plugin_renderer_base {
36
37 /**
38 * Renders the active method selector at the grading method management screen
39 *
d22e9e32 40 * @param grading_manager $manager
6832a102
DM
41 * @param moodle_url $targeturl
42 * @return string
43 */
44 public function management_method_selector(grading_manager $manager, moodle_url $targeturl) {
45
46 $method = $manager->get_active_method();
47 $methods = $manager->get_available_methods(false);
48 $methods['none'] = get_string('gradingmethodnone', 'core_grading');
49 $selector = new single_select(new moodle_url($targeturl, array('sesskey' => sesskey())),
71bd9d20 50 'setmethod', $methods, empty($method) ? 'none' : $method, null, 'activemethodselector');
6832a102
DM
51 $selector->set_label(get_string('changeactivemethod', 'core_grading'));
52 $selector->set_help_icon('gradingmethod', 'core_grading');
53
54 return $this->output->render($selector);
55 }
56
57 /**
58 * Renders an action icon at the gradng method management screen
59 *
60 * @param moodle_url $url action URL
61 * @param string $text action text
62 * @param string $icon the name of the icon to use
63 * @return string
64 */
65 public function management_action_icon(moodle_url $url, $text, $icon) {
66
67 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
68 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
69 return html_writer::link($url, $img . $txt, array('class' => 'action'));
70 }
71
fde33804
DM
72 /**
73 * Renders a message for the user, typically as an action result
74 *
75 * @param string $message
76 * @return string
77 */
78 public function management_message($message) {
79 $this->page->requires->strings_for_js(array('clicktoclose'), 'core_grading');
80 $this->page->requires->yui_module('moodle-core_grading-manage', 'M.core_grading.init_manage');
e01f3f63
R
81 return $this->output->box(format_string($message) . ' - ' . html_writer::tag('span', ''), 'message',
82 'actionresultmessagebox');
fde33804
DM
83 }
84
6832a102 85 /**
20836db9 86 * Renders the template action icon
6832a102 87 *
20836db9
DM
88 * @param moodle_url $url action URL
89 * @param string $text action text
90 * @param string $icon the name of the icon to use
91 * @param string $class extra class of this action
6832a102
DM
92 * @return string
93 */
20836db9 94 public function pick_action_icon(moodle_url $url, $text, $icon = '', $class = '') {
6832a102 95
20836db9
DM
96 $img = html_writer::empty_tag('img', array('src' => $this->output->pix_url($icon), 'class' => 'action-icon'));
97 $txt = html_writer::tag('div', $text, array('class' => 'action-text'));
98 return html_writer::link($url, $img . $txt, array('class' => 'action '.$class));
6832a102
DM
99 }
100}