Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 3 defined('MOODLE_INTERNAL') || die(); 4 5 class mod_data_renderer extends plugin_renderer_base { 6 7 public function import_setting_mappings($datamodule, data_preset_importer $importer) { 8 9 $strblank = get_string('blank', 'data'); 10 $strcontinue = get_string('continue'); 11 $strwarning = get_string('mappingwarning', 'data'); 12 $strfieldmappings = get_string('fieldmappings', 'data'); 13 $strnew = get_string('new'); 14 15 16 $params = $importer->get_preset_settings(); 17 $settings = $params->settings; 18 $newfields = $params->importfields; 19 $currentfields = $params->currentfields; 20 21 $html = html_writer::start_tag('div', array('class'=>'presetmapping')); 22 $html .= html_writer::start_tag('form', array('method'=>'post', 'action'=>'')); 23 $html .= html_writer::start_tag('div'); 24 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'action', 'value'=>'finishimport')); 25 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'sesskey', 'value'=>sesskey())); 26 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'d', 'value'=>$datamodule->id)); 27 28 if ($importer instanceof data_preset_existing_importer) { 29 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'fullname', 'value'=>$importer->get_userid().'/'.$importer->get_directory())); 30 } else { 31 $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'directory', 'value'=>$importer->get_directory())); 32 } 33 34 if (!empty($newfields)) { 35 $html .= $this->output->heading_with_help($strfieldmappings, 'fieldmappings', 'data', '', '', 3); 36 37 $table = new html_table(); 38 $table->data = array(); 39 40 foreach ($newfields as $nid => $newfield) { 41 $row = array(); 42 $row[0] = html_writer::tag('label', $newfield->name, array('for'=>'id_'.$newfield->name)); 43 $attrs = array('name' => 'field_' . $nid, 'id' => 'id_' . $newfield->name, 'class' => 'custom-select'); 44 $row[1] = html_writer::start_tag('select', $attrs); 45 46 $selected = false; 47 foreach ($currentfields as $cid => $currentfield) { 48 if ($currentfield->type != $newfield->type) { 49 continue; 50 } 51 if ($currentfield->name == $newfield->name) { 52 $row[1] .= html_writer::tag('option', get_string('mapexistingfield', 'data', $currentfield->name), array('value'=>$cid, 'selected'=>'selected')); 53 $selected=true; 54 } else { 55 $row[1] .= html_writer::tag('option', get_string('mapexistingfield', 'data', $currentfield->name), array('value'=>$cid)); 56 } 57 } 58 59 if ($selected) { 60 $row[1] .= html_writer::tag('option', get_string('mapnewfield', 'data'), array('value'=>'-1')); 61 } else { 62 $row[1] .= html_writer::tag('option', get_string('mapnewfield', 'data'), array('value'=>'-1', 'selected'=>'selected')); 63 } 64 65 $row[1] .= html_writer::end_tag('select'); 66 $table->data[] = $row; 67 } 68 $html .= html_writer::table($table); 69 $html .= html_writer::tag('p', $strwarning); 70 } else { 71 $html .= $this->output->notification(get_string('nodefinedfields', 'data')); 72 } 73 74 $html .= html_writer::start_tag('div', array('class'=>'overwritesettings')); 75 $html .= html_writer::tag('label', get_string('overwritesettings', 'data'), array('for' => 'overwritesettings')); 76 $attrs = array('type' => 'checkbox', 'name' => 'overwritesettings', 'id' => 'overwritesettings', 'class' => 'ml-1'); 77 $html .= html_writer::empty_tag('input', $attrs); 78 $html .= html_writer::end_tag('div'); 79 $html .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-primary', 'value' => $strcontinue)); 80 81 $html .= html_writer::end_tag('div'); 82 $html .= html_writer::end_tag('form'); 83 $html .= html_writer::end_tag('div'); 84 85 return $html; 86 } 87 88 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body