Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 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 /** 89 * Renders the action bar for the field page. 90 * 91 * @param \mod_data\output\fields_action_bar $actionbar 92 * @return string The HTML output 93 */ 94 public function render_fields_action_bar(\mod_data\output\fields_action_bar $actionbar): string { 95 $data = $actionbar->export_for_template($this); 96 return $this->render_from_template('mod_data/fields_action_bar', $data); 97 } 98 99 /** 100 * Renders the action bar for the view page. 101 * 102 * @param \mod_data\output\view_action_bar $actionbar 103 * @return string The HTML output 104 */ 105 public function render_view_action_bar(\mod_data\output\view_action_bar $actionbar): string { 106 $data = $actionbar->export_for_template($this); 107 return $this->render_from_template('mod_data/view_action_bar', $data); 108 } 109 110 /** 111 * Renders the action bar for the template page. 112 * 113 * @param \mod_data\output\templates_action_bar $actionbar 114 * @return string The HTML output 115 */ 116 public function render_templates_action_bar(\mod_data\output\templates_action_bar $actionbar): string { 117 $data = $actionbar->export_for_template($this); 118 return $this->render_from_template('mod_data/templates_action_bar', $data); 119 } 120 121 /** 122 * Renders the action bar for the preset page. 123 * 124 * @param \mod_data\output\presets_action_bar $actionbar 125 * @return string The HTML output 126 */ 127 public function render_presets_action_bar(\mod_data\output\presets_action_bar $actionbar): string { 128 $data = $actionbar->export_for_template($this); 129 return $this->render_from_template('mod_data/presets_action_bar', $data); 130 } 131 132 /** 133 * Renders the presets table in the preset page. 134 * 135 * @param \mod_data\output\presets $presets 136 * @return string The HTML output 137 */ 138 public function render_presets(\mod_data\output\presets $presets): string { 139 $data = $presets->export_for_template($this); 140 return $this->render_from_template('mod_data/presets', $data); 141 } 142 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body