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 of Language customization admin report
22 * @subpackage customlang
23 * @copyright 2010 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 * Rendering methods for the report widgets
32 class report_customlang_renderer extends plugin_renderer_base {
35 * Renders customlang report menu
39 protected function render_report_customlang_menu(report_customlang_menu $menu) {
41 foreach ($menu->get_items() as $item) {
42 $output .= $this->single_button($item->url, $item->title, $item->method);
44 return $this->box($output, 'menu');
48 * Renders customlang translation table
50 * @param report_customlang_translator $translator
53 protected function render_report_customlang_translator(report_customlang_translator $translator) {
56 if (empty($translator->strings)) {
57 return $this->heading(get_string('nostringsfound', 'report_customlang'), 3);
60 $table = new html_table();
61 $table->id = 'translator';
63 get_string('headingcomponent', 'report_customlang'),
64 get_string('headingstringid', 'report_customlang'),
65 get_string('headingstandard', 'report_customlang'),
66 get_string('headinglocal', 'report_customlang'),
69 foreach ($translator->strings as $string) {
72 $cells[0] = new html_table_cell($string->component);
73 $cells[0]->attributes['class'] = 'component';
74 // string identification code
75 $cells[1] = new html_table_cell(html_writer::tag('div', s($string->stringid), array('class' => 'stringid')));
76 $cells[1]->attributes['class'] = 'stringid';
77 // master translation of the string
78 $cells[2] = new html_table_cell(html_writer::tag('div', s($string->master), array('class' => 'preformatted')));
79 $cells[2]->attributes['class'] = 'standard master';
80 // local customization of the string
81 $textarea = html_writer::tag('textarea', s($string->local), array('name'=>'cust['.$string->id.']'));
82 $cells[3] = new html_table_cell($textarea);
83 if (!is_null($string->local) and $string->outdated) {
84 $mark = html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'update_' . $string->id,
85 'name' => 'updates[]', 'value' => $string->id));
86 $help = $this->help_icon('markinguptodate', 'report_customlang');
87 $mark .= html_writer::tag('label', get_string('markuptodate', 'report_customlang') . $help,
88 array('for' => 'update_' . $string->id));
89 $mark = html_writer::tag('div', $mark, array('class' => 'uptodatewrapper'));
93 $cells[3] = new html_table_cell($textarea."\n".$mark);
94 $cells[3]->attributes['class'] = 'local';
95 $cells[3]->id = 'id_'.$string->id;
96 if (!is_null($string->local)) {
97 $cells[3]->attributes['class'] .= ' customized';
99 if ($string->outdated) {
100 $cells[3]->attributes['class'] .= ' outdated';
102 if ($string->modified) {
103 $cells[3]->attributes['class'] .= ' modified';
106 if ($string->original !== $string->master) {
107 $cells[0]->rowspan = $cells[1]->rowspan = $cells[3]->rowspan = 2;
110 $row = new html_table_row($cells);
111 $table->data[] = $row;
113 if ($string->original !== $string->master) {
115 // original of the string
116 $cells[2] = new html_table_cell(html_writer::tag('div', s($string->original), array('class' => 'preformatted')));
117 $cells[2]->attributes['class'] = 'standard original';
118 $row = new html_table_row($cells);
119 $table->data[] = $row;
123 $output .= html_writer::start_tag('form', array('method'=>'post', 'action'=>$translator->handler->out()));
124 $output .= html_writer::start_tag('div');
125 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'translatorsubmitted', 'value'=>1));
126 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey()));
127 $save1 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecontinue', 'value'=>get_string('savecontinue', 'report_customlang')));
128 $save2 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecheckin', 'value'=>get_string('savecheckin', 'report_customlang')));
129 $output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
130 $output .= html_writer::table($table);
131 $output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar'));
132 $output .= html_writer::end_tag('div');
133 $output .= html_writer::end_tag('form');