[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 * Output rendering of Language customization admin tool 19 * 20 * @package tool 21 * @subpackage customlang 22 * @copyright 2010 David Mudrak <david@moodle.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 /** 29 * Rendering methods for the tool widgets 30 */ 31 class tool_customlang_renderer extends plugin_renderer_base { 32 33 /** 34 * Renders customlang tool menu 35 * 36 * @return string HTML 37 */ 38 protected function render_tool_customlang_menu(tool_customlang_menu $menu) { 39 $output = ''; 40 foreach ($menu->get_items() as $item) { 41 $output .= $this->single_button($item->url, $item->title, $item->method); 42 } 43 return $this->box($output, 'menu'); 44 } 45 46 /** 47 * Renders customlang translation table 48 * 49 * @param tool_customlang_translator $translator 50 * @return string HTML 51 */ 52 protected function render_tool_customlang_translator(tool_customlang_translator $translator) { 53 $output = ''; 54 55 if (empty($translator->strings)) { 56 return $this->notification(get_string('nostringsfound', 'tool_customlang')); 57 } 58 59 $table = new html_table(); 60 $table->id = 'translator'; 61 $table->head = array( 62 get_string('headingcomponent', 'tool_customlang'), 63 get_string('headingstringid', 'tool_customlang'), 64 get_string('headingstandard', 'tool_customlang'), 65 get_string('headinglocal', 'tool_customlang'), 66 ); 67 68 foreach ($translator->strings as $string) { 69 $cells = array(); 70 // component name 71 $cells[0] = new html_table_cell($string->component); 72 $cells[0]->attributes['class'] = 'component'; 73 // string identification code 74 $cells[1] = new html_table_cell(html_writer::tag('div', s($string->stringid), array('class' => 'stringid'))); 75 $cells[1]->attributes['class'] = 'stringid'; 76 // master translation of the string 77 $master = html_writer::tag('div', s($string->master), array('class' => 'preformatted')); 78 $minheight = strlen($string->master) / 200; 79 if (preg_match('/\{\$a(->.+)?\}/', $string->master)) { 80 $master .= html_writer::tag('div', $this->help_icon('placeholder', 'tool_customlang', 81 get_string('placeholderwarning', 'tool_customlang')), array('class' => 'placeholderinfo')); 82 } 83 $cells[2] = new html_table_cell($master); 84 $cells[2]->attributes['class'] = 'standard master'; 85 // local customization of the string 86 $textareaattributes = array('name'=>'cust['.$string->id.']', 'cols'=>40, 'rows'=>3); 87 if ($minheight>1) { 88 $textareaattributes['style'] = 'min-height:' . (int) 4*$minheight . 'em;'; 89 } 90 $textarea = html_writer::tag('textarea', s($string->local), $textareaattributes); 91 $cells[3] = new html_table_cell($textarea); 92 if (!is_null($string->local) and $string->outdated) { 93 $mark = html_writer::empty_tag('input', array('type' => 'checkbox', 'id' => 'update_' . $string->id, 94 'name' => 'updates[]', 'value' => $string->id)); 95 $help = $this->help_icon('markinguptodate', 'tool_customlang'); 96 $mark .= html_writer::tag('label', get_string('markuptodate', 'tool_customlang') . $help, 97 array('for' => 'update_' . $string->id)); 98 $mark = html_writer::tag('div', $mark, array('class' => 'uptodatewrapper')); 99 } else { 100 $mark = ''; 101 } 102 $cells[3] = new html_table_cell($textarea."\n".$mark); 103 $cells[3]->attributes['class'] = 'local'; 104 $cells[3]->id = 'id_'.$string->id; 105 if (!is_null($string->local)) { 106 $cells[3]->attributes['class'] .= ' customized'; 107 } 108 if ($string->outdated) { 109 $cells[3]->attributes['class'] .= ' outdated'; 110 } 111 if ($string->modified) { 112 $cells[3]->attributes['class'] .= ' modified'; 113 } 114 115 if ($string->original !== $string->master) { 116 $cells[0]->rowspan = $cells[1]->rowspan = $cells[3]->rowspan = 2; 117 } 118 119 $row = new html_table_row($cells); 120 $table->data[] = $row; 121 122 if ($string->original !== $string->master) { 123 $cells = array(); 124 // original of the string 125 $cells[2] = new html_table_cell(html_writer::tag('div', s($string->original), array('class' => 'preformatted'))); 126 $cells[2]->attributes['class'] = 'standard original'; 127 $row = new html_table_row($cells); 128 $table->data[] = $row; 129 } 130 } 131 132 $output .= html_writer::start_tag('form', array('method'=>'post', 'action'=>$translator->handler->out())); 133 $output .= html_writer::start_tag('div'); 134 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'translatorsubmitted', 'value'=>1)); 135 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey())); 136 $output .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'p', 'value'=>$translator->currentpage)); 137 $save1 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecontinue', 'value'=>get_string('savecontinue', 'tool_customlang'))); 138 $save2 = html_writer::empty_tag('input', array('type'=>'submit', 'name'=>'savecheckin', 'value'=>get_string('savecheckin', 'tool_customlang'))); 139 $output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar')); 140 $output .= html_writer::table($table); 141 $output .= html_writer::tag('fieldset', $save1.$save2, array('class'=>'buttonsbar')); 142 $output .= html_writer::end_tag('div'); 143 $output .= html_writer::end_tag('form'); 144 145 return $output; 146 } 147 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |