From e85fda95c68891295edef9e05aad62f52e47b7aa Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 3 Nov 2016 17:03:03 +0800 Subject: [PATCH 1/3] MDL-56725 mod_data: Style fixes for boost theme --- mod/data/edit.php | 6 ++--- mod/data/export_form.php | 2 +- mod/data/field.php | 9 ++++---- mod/data/field/checkbox/field.class.php | 8 +++---- mod/data/field/date/field.class.php | 4 ++-- mod/data/field/file/field.class.php | 2 +- mod/data/field/latlong/field.class.php | 16 ++++++------- mod/data/field/menu/field.class.php | 4 ++-- mod/data/field/multimenu/field.class.php | 6 ++--- mod/data/field/number/field.class.php | 2 +- mod/data/field/picture/field.class.php | 4 ++-- mod/data/field/radiobutton/field.class.php | 4 ++-- mod/data/field/text/field.class.php | 2 +- mod/data/field/textarea/field.class.php | 2 +- mod/data/field/url/field.class.php | 14 ++++++------ mod/data/lib.php | 26 +++++++++++----------- mod/data/renderer.php | 6 ++--- mod/data/styles.css | 8 ------- mod/data/templates.php | 14 ++++++------ mod/data/view.php | 3 +++ 20 files changed, 69 insertions(+), 73 deletions(-) diff --git a/mod/data/edit.php b/mod/data/edit.php index 132f600438c..39af5e2bc8f 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -352,12 +352,12 @@ foreach ($generalnotifications as $notification) { } echo $newtext; -echo '
'; +echo '
'; if ($rid) { - echo ' '; + echo ' '; } else { if ((!$data->maxentries) || has_capability('mod/data:manageentries', $context) || (data_numentries($data) < ($data->maxentries - 1))) { - echo ' '; + echo ' '; } } echo '
'; diff --git a/mod/data/export_form.php b/mod/data/export_form.php index c0383f29dfa..a5abd773015 100644 --- a/mod/data/export_form.php +++ b/mod/data/export_form.php @@ -59,7 +59,7 @@ class mod_data_export_form extends moodleform { $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data')); foreach($this->_datafields as $field) { if($field->text_export_supported()) { - $mform->addElement('advcheckbox', 'field_'.$field->field->id, '
' . $field->field->name . '
', ' (' . $field->name() . ')', array('group'=>1)); + $mform->addElement('advcheckbox', 'field_'.$field->field->id, '
' . $field->field->name . '
', ' (' . $field->name() . ')', array('group'=>1)); $mform->setDefault('field_'.$field->field->id, 1); } else { $a = new stdClass(); diff --git a/mod/data/field.php b/mod/data/field.php index 9ffab95c88b..d5040afc690 100644 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -312,7 +312,8 @@ if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// echo '
'; $popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey(); echo $OUTPUT->single_select(new moodle_url($popupurl), 'newtype', $menufield, null, array('' => 'choosedots'), - 'fieldform', array('label' => get_string('newfield', 'data') . $OUTPUT->help_icon('newfield', 'data'))); + 'fieldform', array('label' => get_string('newfield', 'data'))); + echo $OUTPUT->help_icon('newfield', 'data'); echo '
'; echo '
'; @@ -322,7 +323,7 @@ if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// echo ''; echo ''; echo ''; - echo ''; if ($fields = $DB->get_records('data_fields', array('dataid'=>$data->id))) { echo ''; foreach ($fields as $field) { @@ -357,8 +358,8 @@ if (($mode == 'new') && (!empty($newtype)) && confirm_sesskey()) { /// $options = array(0 => get_string('ascending', 'data'), 1 => get_string('descending', 'data')); echo html_writer::label(get_string('sortby'), 'menudefaultsortdir', false, array('class' => 'accesshide')); - echo html_writer::select($options, 'defaultsortdir', $data->defaultsortdir, false); - echo ''; + echo html_writer::select($options, 'defaultsortdir', $data->defaultsortdir, false, array('class' => 'custom-select')); + echo ''; echo '
'; echo ''; echo '
'; diff --git a/mod/data/field/checkbox/field.class.php b/mod/data/field/checkbox/field.class.php index d3726fa2bcc..f1b46dbe24c 100644 --- a/mod/data/field/checkbox/field.class.php +++ b/mod/data/field/checkbox/field.class.php @@ -67,7 +67,7 @@ class data_field_checkbox extends data_field_base { } $str .= ''; $str .= 'field->id.'[]', s($checkbox), true, $checkbox); + $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), true, $checkbox, array('class' => 'm-r-1')); } else { - $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), false, $checkbox); + $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), false, $checkbox, array('class' => 'm-r-1')); } $str .= html_writer::empty_tag('br'); $found = true; @@ -110,7 +110,7 @@ class data_field_checkbox extends data_field_base { return ''; } - $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data')); + $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data'), array('class' => 'm-r-1')); return $str; } diff --git a/mod/data/field/date/field.class.php b/mod/data/field/date/field.class.php index 600e0e9be14..319727b85b1 100644 --- a/mod/data/field/date/field.class.php +++ b/mod/data/field/date/field.class.php @@ -62,7 +62,7 @@ class data_field_date extends data_field_base { $content = time(); } - $str = '
'; + $str = '
'; $dayselector = html_writer::select_time('days', 'field_'.$this->field->id.'_day', $content); $monthselector = html_writer::select_time('months', 'field_'.$this->field->id.'_month', $content); $yearselector = html_writer::select_time('years', 'field_'.$this->field->id.'_year', $content); @@ -78,7 +78,7 @@ class data_field_date extends data_field_base { . html_writer::select_time('months', 'f_'.$this->field->id.'_m', $value['timestamp']) . html_writer::select_time('years', 'f_'.$this->field->id.'_y', $value['timestamp']); $datecheck = html_writer::checkbox('f_'.$this->field->id.'_z', 1, $value['usedate']); - $str = $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data'); + $str = '
' . $selectors . ' ' . $datecheck . ' ' . get_string('usedate', 'data') . '
'; return $str; } diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 705c3db2b9b..522e11f52fe 100644 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -104,7 +104,7 @@ class data_field_file extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function generate_sql($tablealias, $value) { diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index e922359b2d9..cbe567567bc 100644 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -61,21 +61,21 @@ class data_field_latlong extends data_field_base { } $str = '
'; $str .= '
'.$this->field->name.''; - $str .= ''; + $str .= ''; + $str .= ''; $str .= ''; - echo ''; + echo ''; echo '
'; - $str .= ''; $str .= html_writer::select($options, 'field_'.$this->field->id, $content, array('' => get_string('menuchoose', 'data')), - array('id' => 'field_'.$this->field->id, 'class' => 'mod-data-input')); + array('id' => 'field_'.$this->field->id, 'class' => 'mod-data-input custom-select')); $str .= ''; @@ -105,7 +105,7 @@ class data_field_menu extends data_field_base { $return = html_writer::label(get_string('fieldtypelabel', "datafield_" . $this->type), 'menuf_' . $this->field->id, false, array('class' => 'accesshide')); - $return .= html_writer::select($options, 'f_'.$this->field->id, $content); + $return .= html_writer::select($options, 'f_'.$this->field->id, $content, array('class' => 'custom-select')); return $return; } diff --git a/mod/data/field/multimenu/field.class.php b/mod/data/field/multimenu/field.class.php index a6555f64573..333375b1ee2 100644 --- a/mod/data/field/multimenu/field.class.php +++ b/mod/data/field/multimenu/field.class.php @@ -62,7 +62,7 @@ class data_field_multimenu extends data_field_base { } $str .= ''; $str .= ''; + $str .= ''; - $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data')); + $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data'), array('class' => 'm-r-1')); return $str; diff --git a/mod/data/field/number/field.class.php b/mod/data/field/number/field.class.php index da797ccba12..ea01aa5e6f5 100644 --- a/mod/data/field/number/field.class.php +++ b/mod/data/field/number/field.class.php @@ -71,7 +71,7 @@ class data_field_number extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 571fd739b97..f620a6747c4 100644 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -110,7 +110,7 @@ class data_field_picture extends data_field_base { $str .= '
'; $str .= ''; - $str .= ' field->id.'_alttext">'.get_string('alttext','data') .' '; $str .= '
'; $str .= ''; @@ -140,7 +140,7 @@ class data_field_picture extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/field/radiobutton/field.class.php b/mod/data/field/radiobutton/field.class.php index dbc5c1e29ed..da00d80a6b8 100644 --- a/mod/data/field/radiobutton/field.class.php +++ b/mod/data/field/radiobutton/field.class.php @@ -69,7 +69,7 @@ class data_field_radiobutton extends data_field_base { continue; // skip empty lines } $str .= 'type), 'menuf_' . $this->field->id, false, array('class' => 'accesshide')); - $return .= html_writer::select($options, 'f_'.$this->field->id, $value); + $return .= html_writer::select($options, 'f_'.$this->field->id, $value, null, array('class' => 'custom-select')); return $return; } diff --git a/mod/data/field/text/field.class.php b/mod/data/field/text/field.class.php index dd72649249e..fea218508dd 100644 --- a/mod/data/field/text/field.class.php +++ b/mod/data/field/text/field.class.php @@ -33,7 +33,7 @@ class data_field_text extends data_field_base { protected static $priority = self::MAX_PRIORITY; function display_search_field($value = '') { - return '' . ''; + return '' . ''; } function parse_search_field() { diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index cdb46fcdfcb..ec9b6610fa7 100644 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -172,7 +172,7 @@ class data_field_textarea extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/field/url/field.class.php b/mod/data/field/url/field.class.php index 6769c81a764..fb32bdb888c 100644 --- a/mod/data/field/url/field.class.php +++ b/mod/data/field/url/field.class.php @@ -65,7 +65,7 @@ class data_field_url extends data_field_base { $autolinkable = !empty($this->field->param1) and empty($this->field->param2); - $str = '
'; + $str = '
'; $label = '
'; $str .= $label; - $str .= ''; - $str .= '
'.get_string('text', 'data').':'; $str .= 'field->id.'_0" id="'.$fieldid.'" value="'.s($url).'"'; - $str .= ' size="60" class="mod-data-input" />'; + $str .= ' size="40" class="mod-data-input form-control d-inline" />'; if (count($options->repositories) > 0) { - $str .= ''; + $str .= ''; } } @@ -114,7 +114,7 @@ class data_field_url extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/lib.php b/mod/data/lib.php index 050f5a9a84c..0fc5b0f4a5d 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -308,7 +308,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/ array('class' => 'req', 'title' => get_string('requiredelement', 'form'))); $str .= html_writer::div($image, 'inline-req'); } - $str .= 'field->id.'"'; $str .= ' id="field_' . $this->field->id . '" value="'.s($content).'" />'; $str .= ''; @@ -349,8 +349,8 @@ class data_field_base { // Base class for Database Field Types (see field/*/ require_once($CFG->dirroot.'/mod/data/field/'.$this->type.'/mod.html'); echo '
'; - echo ''."\n"; - echo ''."\n"; + echo ''."\n"; + echo ''."\n"; echo '
'; echo ''; @@ -1663,7 +1663,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo ' '; $pagesizes = array(2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10,15=>15, 20=>20,30=>30,40=>40,50=>50,100=>100,200=>200,300=>300,400=>400,500=>500,1000=>1000); - echo html_writer::select($pagesizes, 'perpage', $perpage, false, array('id'=>'pref_perpage')); + echo html_writer::select($pagesizes, 'perpage', $perpage, false, array('id'=>'pref_perpage', 'class' => 'custom-select')); if ($advanced) { $regsearchclass = 'search_none'; @@ -1672,11 +1672,11 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' $regsearchclass = 'search_inline'; $advancedsearchclass = 'search_none'; } - echo ''; + echo ''; echo '    '; // foreach field, print the option - echo ''; if ($fields = $DB->get_records('data_fields', array('dataid'=>$data->id), 'name')) { echo ''; foreach ($fields as $field) { @@ -1707,7 +1707,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo ''; echo ''; echo ''; - echo ''; if ($order == 'ASC') { echo ''; } else { @@ -1729,8 +1729,8 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' $PAGE->requires->js('/mod/data/data.js'); echo ' '; echo ' '; - echo ' '; - echo ' '; + echo ' '; + echo ' '; echo '
'; echo '
'; @@ -1781,9 +1781,9 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' $fn = !empty($search_array[DATA_FIRSTNAME]->data) ? $search_array[DATA_FIRSTNAME]->data : ''; $ln = !empty($search_array[DATA_LASTNAME]->data) ? $search_array[DATA_LASTNAME]->data : ''; $patterns[] = '/##firstname##/'; - $replacement[] = ''; + $replacement[] = ''; $patterns[] = '/##lastname##/'; - $replacement[] = ''; + $replacement[] = ''; // actual replacement of the tags $newtext = preg_replace($patterns, $replacement, $data->asearchtemplate); @@ -1795,7 +1795,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo format_text($newtext, FORMAT_HTML, $options); echo '


'; echo '
'; echo '
'; diff --git a/mod/data/renderer.php b/mod/data/renderer.php index a8d0e6ccacd..1b065354fc3 100644 --- a/mod/data/renderer.php +++ b/mod/data/renderer.php @@ -40,7 +40,7 @@ class mod_data_renderer extends plugin_renderer_base { foreach ($newfields as $nid => $newfield) { $row = array(); $row[0] = html_writer::tag('label', $newfield->name, array('for'=>'id_'.$newfield->name)); - $row[1] = html_writer::start_tag('select', array('name'=>'field_'.$nid, 'id'=>'id_'.$newfield->name)); + $row[1] = html_writer::start_tag('select', array('name'=>'field_'.$nid, 'id'=>'id_'.$newfield->name, 'class' => 'custom-select')); $selected = false; foreach ($currentfields as $cid => $currentfield) { @@ -72,9 +72,9 @@ class mod_data_renderer extends plugin_renderer_base { $html .= html_writer::start_tag('div', array('class'=>'overwritesettings')); $html .= html_writer::tag('label', get_string('overwritesettings', 'data'), array('for'=>'overwritesettings')); - $html .= html_writer::empty_tag('input', array('type'=>'checkbox', 'name'=>'overwritesettings', 'id'=>'overwritesettings')); + $html .= html_writer::empty_tag('input', array('type'=>'checkbox', 'name'=>'overwritesettings', 'id'=>'overwritesettings', 'class'=>'m-l-1')); $html .= html_writer::end_tag('div'); - $html .= html_writer::empty_tag('input', array('type'=>'submit', 'class'=>'button', 'value'=>$strcontinue)); + $html .= html_writer::empty_tag('input', array('type'=>'submit', 'class'=>'btn btn-primary', 'value'=>$strcontinue)); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); diff --git a/mod/data/styles.css b/mod/data/styles.css index 186e3756371..ec549cc1058 100644 --- a/mod/data/styles.css +++ b/mod/data/styles.css @@ -1,11 +1,3 @@ -.path-mod-data .fieldadd, -.path-mod-data .sortdefault, -.path-mod-data .defaulttemplate, -#page-mod-data-view .datapreferences, -#page-mod-data-preset .presetmapping { - text-align: center; -} - .path-mod-data-field .c0, #page-mod-data-view #sortsearch .c0 { text-align: right; diff --git a/mod/data/templates.php b/mod/data/templates.php index 77953162f84..704bfa5eadb 100644 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -241,7 +241,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { echo '
'; echo '
'; - echo ''; $fields = $DB->get_records('data_fields', array('dataid'=>$data->id)); echo ''; @@ -300,7 +300,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { echo ''; echo '
'; - echo '



'; + echo '



'; echo '

'; if ($usehtmleditor) { $switchlink = new moodle_url($PAGE->url, ['useeditor' => false]); @@ -315,7 +315,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { ]); } } else { - echo '



'; + echo '



'; } echo ''; @@ -329,7 +329,7 @@ if ($mode == 'listtemplate'){ $field = 'template'; $editor->set_text($data->{$mode}); $editor->use_editor($field, $options); -echo '
'; +echo '
'; echo ''; echo ''; @@ -342,7 +342,7 @@ if ($mode == 'listtemplate'){ $field = 'listtemplatefooter'; $editor->set_text($data->listtemplatefooter); $editor->use_editor($field, $options); - echo '
'; + echo '
'; echo ''; echo ''; } else if ($mode == 'rsstemplate') { @@ -354,13 +354,13 @@ if ($mode == 'listtemplate'){ $field = 'rsstitletemplate'; $editor->set_text($data->rsstitletemplate); $editor->use_editor($field, $options); - echo '
'; + echo '
'; echo ''; echo ''; } echo ''; -echo ' '; +echo ' '; echo ''; diff --git a/mod/data/view.php b/mod/data/view.php index fb322db53ed..c2174c9185f 100644 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -824,16 +824,19 @@ if ($showactivity) { 'type' => 'button', 'id' => 'checkall', 'value' => get_string('selectall'), + 'class' => 'btn btn-secondary m-r-1' )); echo html_writer::empty_tag('input', array( 'type' => 'button', 'id' => 'checknone', 'value' => get_string('deselectall'), + 'class' => 'btn btn-secondary m-r-1' )); echo html_writer::empty_tag('input', array( 'class' => 'form-submit', 'type' => 'submit', 'value' => get_string('deleteselected'), + 'class' => 'btn btn-secondary m-r-1' )); $module = array('name' => 'mod_data', 'fullpath' => '/mod/data/module.js'); From 398be7c897f37ea87eef4664cdc1e984f5250dbd Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 4 Nov 2016 11:30:11 +0800 Subject: [PATCH 2/3] MDL-56725 mod_data: coding style Fixes from lines in the previous commit. --- mod/data/edit.php | 13 ++++++++---- mod/data/export_form.php | 13 ++++++++---- mod/data/field/checkbox/field.class.php | 9 ++++---- mod/data/field/file/field.class.php | 3 ++- mod/data/field/latlong/field.class.php | 24 +++++++++++++++------ mod/data/field/multimenu/field.class.php | 3 ++- mod/data/field/number/field.class.php | 3 ++- mod/data/field/picture/field.class.php | 13 +++++++----- mod/data/field/text/field.class.php | 4 +++- mod/data/field/textarea/field.class.php | 3 ++- mod/data/field/url/field.class.php | 20 +++++++++++------- mod/data/lib.php | 27 ++++++++++++++++-------- mod/data/renderer.php | 10 +++++---- mod/data/templates.php | 25 ++++++++++++++++------ 14 files changed, 114 insertions(+), 56 deletions(-) diff --git a/mod/data/edit.php b/mod/data/edit.php index 39af5e2bc8f..4dcf608e573 100644 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -352,12 +352,17 @@ foreach ($generalnotifications as $notification) { } echo $newtext; -echo '
'; +echo '
'; if ($rid) { - echo ' '; + echo ' '; } else { - if ((!$data->maxentries) || has_capability('mod/data:manageentries', $context) || (data_numentries($data) < ($data->maxentries - 1))) { - echo ' '; + if ((!$data->maxentries) || + has_capability('mod/data:manageentries', $context) || + (data_numentries($data) < ($data->maxentries - 1))) { + echo ' '; } } echo '
'; diff --git a/mod/data/export_form.php b/mod/data/export_form.php index a5abd773015..1377e6c73a6 100644 --- a/mod/data/export_form.php +++ b/mod/data/export_form.php @@ -41,7 +41,8 @@ class mod_data_export_form extends moodleform { unset($choices[$key]); } $typesarray = array(); - $typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('csvwithselecteddelimiter', 'data') . ' ', 'csv'); + $str = get_string('csvwithselecteddelimiter', 'data'); + $typesarray[] = $mform->createElement('radio', 'exporttype', null, $str . ' ', 'csv'); $typesarray[] = $mform->createElement('select', 'delimiter_name', null, $choices); //temporarily commenting out Excel export option. See MDL-19864 //$typesarray[] = $mform->createElement('radio', 'exporttype', null, get_string('excel', 'data'), 'xls'); @@ -59,12 +60,16 @@ class mod_data_export_form extends moodleform { $mform->addElement('header', 'notice', get_string('chooseexportfields', 'data')); foreach($this->_datafields as $field) { if($field->text_export_supported()) { - $mform->addElement('advcheckbox', 'field_'.$field->field->id, '
' . $field->field->name . '
', ' (' . $field->name() . ')', array('group'=>1)); - $mform->setDefault('field_'.$field->field->id, 1); + $html = '
' . $field->field->name . '
'; + $name = ' (' . $field->name() . ')'; + $mform->addElement('advcheckbox', 'field_' . $field->field->id, $html, $name, array('group' => 1)); + $mform->setDefault('field_' . $field->field->id, 1); } else { $a = new stdClass(); $a->fieldtype = $field->name(); - $mform->addElement('static', 'unsupported'.$field->field->id, $field->field->name, get_string('unsupportedexport', 'data', $a)); + $str = get_string('unsupportedexport', 'data', $a); + $mform->addElement('static', 'unsupported' . $field->field->id, $field->field->name, $str); } } $this->add_checkbox_controller(1, null, null, 1); diff --git a/mod/data/field/checkbox/field.class.php b/mod/data/field/checkbox/field.class.php index f1b46dbe24c..4a871c44843 100644 --- a/mod/data/field/checkbox/field.class.php +++ b/mod/data/field/checkbox/field.class.php @@ -95,13 +95,13 @@ class data_field_checkbox extends data_field_base { $str = ''; $found = false; + $marginclass = ['class' => 'm-r-1']; foreach (explode("\n",$this->field->param1) as $checkbox) { $checkbox = trim($checkbox); - if (in_array($checkbox, $content)) { - $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), true, $checkbox, array('class' => 'm-r-1')); + $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), true, $checkbox, $marginclass); } else { - $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), false, $checkbox, array('class' => 'm-r-1')); + $str .= html_writer::checkbox('f_'.$this->field->id.'[]', s($checkbox), false, $checkbox, $marginclass); } $str .= html_writer::empty_tag('br'); $found = true; @@ -110,7 +110,8 @@ class data_field_checkbox extends data_field_base { return ''; } - $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data'), array('class' => 'm-r-1')); + $requiredstr = get_string('selectedrequired', 'data'); + $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, $requiredstr, $marginclass); return $str; } diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 522e11f52fe..363fe847c35 100644 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -104,7 +104,8 @@ class data_field_file extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function generate_sql($tablealias, $value) { diff --git a/mod/data/field/latlong/field.class.php b/mod/data/field/latlong/field.class.php index cbe567567bc..ce9fba78423 100644 --- a/mod/data/field/latlong/field.class.php +++ b/mod/data/field/latlong/field.class.php @@ -62,20 +62,27 @@ class data_field_latlong extends data_field_base { $str = '
'; $str .= '
'.$this->field->name.''; $str .= ''; - $str .= ''; $str .= ''; $str .= '
'; - $str .= 'field->id.'_0" value="'; $str .= s($lat).'" size="10" />°N
field->id.'_1" id="field_'.$this->field->id.'_1" value="'; $str .= s($long).'" size="10" />°E
'; @@ -103,8 +110,10 @@ class data_field_latlong extends data_field_base { } $latlongsrs->close(); - $return = html_writer::label(get_string('latlong', 'data'), 'menuf_'.$this->field->id, false, array('class' => 'accesshide')); - $return .= html_writer::select($options, 'f_'.$this->field->id, $value, null, array('class' => 'custom-select')); + $classes = array('class' => 'accesshide'); + $return = html_writer::label(get_string('latlong', 'data'), 'menuf_'.$this->field->id, false, $classes); + $classes = array('class' => 'custom-select'); + $return .= html_writer::select($options, 'f_'.$this->field->id, $value, null, $classes); return $return; } @@ -185,7 +194,8 @@ class data_field_latlong extends data_field_base { } // NB! If you are editing this, make sure you don't break the javascript reference "previousSibling" // which allows the "Go" button to refer to the drop-down selector. - $str .= "\n"; + $str .= '\n'; $str .= ''; } else { $str = "$compasslat, $compasslong"; diff --git a/mod/data/field/multimenu/field.class.php b/mod/data/field/multimenu/field.class.php index 333375b1ee2..7ab1405a377 100644 --- a/mod/data/field/multimenu/field.class.php +++ b/mod/data/field/multimenu/field.class.php @@ -140,7 +140,8 @@ class data_field_multimenu extends data_field_base { $str .= ''; - $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, get_string('selectedrequired', 'data'), array('class' => 'm-r-1')); + $str .= html_writer::checkbox('f_'.$this->field->id.'_allreq', null, $allrequired, + get_string('selectedrequired', 'data'), array('class' => 'm-r-1')); return $str; diff --git a/mod/data/field/number/field.class.php b/mod/data/field/number/field.class.php index ea01aa5e6f5..dc116156101 100644 --- a/mod/data/field/number/field.class.php +++ b/mod/data/field/number/field.class.php @@ -71,7 +71,8 @@ class data_field_number extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index f620a6747c4..8007b905794 100644 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -109,9 +109,11 @@ class data_field_picture extends data_field_base { $str .= $output->render($fm); $str .= '
'; - $str .= ''; - $str .= ' '; + $str .= ''; + $str .= ' '; $str .= '
'; $str .= '
'; @@ -139,8 +141,9 @@ class data_field_picture extends data_field_base { } function display_search_field($value = '') { - return '' . - ''; + return '' . + ''; } function parse_search_field() { diff --git a/mod/data/field/text/field.class.php b/mod/data/field/text/field.class.php index fea218508dd..4c255953c3e 100644 --- a/mod/data/field/text/field.class.php +++ b/mod/data/field/text/field.class.php @@ -33,7 +33,9 @@ class data_field_text extends data_field_base { protected static $priority = self::MAX_PRIORITY; function display_search_field($value = '') { - return '' . ''; + return '' . + ''; } function parse_search_field() { diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index ec9b6610fa7..0fbd34ca352 100644 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -172,7 +172,8 @@ class data_field_textarea extends data_field_base { function display_search_field($value = '') { return '' . - ''; + ''; } function parse_search_field() { diff --git a/mod/data/field/url/field.class.php b/mod/data/field/url/field.class.php index fb32bdb888c..38b719474b3 100644 --- a/mod/data/field/url/field.class.php +++ b/mod/data/field/url/field.class.php @@ -87,11 +87,13 @@ class data_field_url extends data_field_base { } $str .= ''; $str .= $label; - $str .= ''; - $str .= ''; - $str .= ''.get_string('text', 'data').':'; - $str .= 'field->id . '_0" id="' . $fieldid . '" value="' . s($url) . '" ' . + 'size="40" class="form-control d-inline"/>'; + $str .= ''; + $str .= '' . get_string('text', 'data') . ':'; + $str .= ''; $str .= ''; } else { // Just the URL field @@ -99,7 +101,8 @@ class data_field_url extends data_field_base { $str .= 'repositories) > 0) { - $str .= ''; + $str .= ''; } } @@ -113,8 +116,9 @@ class data_field_url extends data_field_base { } function display_search_field($value = '') { - return '' . - ''; + return '' . + ''; } function parse_search_field() { diff --git a/mod/data/lib.php b/mod/data/lib.php index 0fc5b0f4a5d..2d859c30989 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -308,8 +308,9 @@ class data_field_base { // Base class for Database Field Types (see field/*/ array('class' => 'req', 'title' => get_string('requiredelement', 'form'))); $str .= html_writer::div($image, 'inline-req'); } - $str .= 'field->id . '" value="'.s($content).'" />'; + $str .= ''; $str .= '
'; return $str; @@ -1663,7 +1664,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo ' '; $pagesizes = array(2=>2,3=>3,4=>4,5=>5,6=>6,7=>7,8=>8,9=>9,10=>10,15=>15, 20=>20,30=>30,40=>40,50=>50,100=>100,200=>200,300=>300,400=>400,500=>500,1000=>1000); - echo html_writer::select($pagesizes, 'perpage', $perpage, false, array('id'=>'pref_perpage', 'class' => 'custom-select')); + echo html_writer::select($pagesizes, 'perpage', $perpage, false, array('id' => 'pref_perpage', 'class' => 'custom-select')); if ($advanced) { $regsearchclass = 'search_none'; @@ -1673,7 +1674,8 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' $advancedsearchclass = 'search_none'; } echo ''; + echo '
'; echo '    '; // foreach field, print the option echo ''; echo ' '; - echo ' '; - echo ' '; + echo ' ' . + ''; + echo ' '; echo '
'; echo '
'; @@ -1781,9 +1785,11 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' $fn = !empty($search_array[DATA_FIRSTNAME]->data) ? $search_array[DATA_FIRSTNAME]->data : ''; $ln = !empty($search_array[DATA_LASTNAME]->data) ? $search_array[DATA_LASTNAME]->data : ''; $patterns[] = '/##firstname##/'; - $replacement[] = ''; + $replacement[] = '' . + ''; $patterns[] = '/##lastname##/'; - $replacement[] = ''; + $replacement[] = '' . + ''; // actual replacement of the tags $newtext = preg_replace($patterns, $replacement, $data->asearchtemplate); @@ -1795,7 +1801,10 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' echo format_text($newtext, FORMAT_HTML, $options); echo ''; - echo '
'; + echo '
' . + '' . + '' . + ''; echo ''; echo '
'; echo ''; diff --git a/mod/data/renderer.php b/mod/data/renderer.php index 1b065354fc3..2056e6e462b 100644 --- a/mod/data/renderer.php +++ b/mod/data/renderer.php @@ -40,7 +40,8 @@ class mod_data_renderer extends plugin_renderer_base { foreach ($newfields as $nid => $newfield) { $row = array(); $row[0] = html_writer::tag('label', $newfield->name, array('for'=>'id_'.$newfield->name)); - $row[1] = html_writer::start_tag('select', array('name'=>'field_'.$nid, 'id'=>'id_'.$newfield->name, 'class' => 'custom-select')); + $attrs = array('name' => 'field_' . $nid, 'id' => 'id_' . $newfield->name, 'class' => 'custom-select'); + $row[1] = html_writer::start_tag('select', $attrs); $selected = false; foreach ($currentfields as $cid => $currentfield) { @@ -71,10 +72,11 @@ class mod_data_renderer extends plugin_renderer_base { } $html .= html_writer::start_tag('div', array('class'=>'overwritesettings')); - $html .= html_writer::tag('label', get_string('overwritesettings', 'data'), array('for'=>'overwritesettings')); - $html .= html_writer::empty_tag('input', array('type'=>'checkbox', 'name'=>'overwritesettings', 'id'=>'overwritesettings', 'class'=>'m-l-1')); + $html .= html_writer::tag('label', get_string('overwritesettings', 'data'), array('for' => 'overwritesettings')); + $attrs = array('type' => 'checkbox', 'name' => 'overwritesettings', 'id' => 'overwritesettings', 'class' => 'm-l-1'); + $html .= html_writer::empty_tag('input', $attrs); $html .= html_writer::end_tag('div'); - $html .= html_writer::empty_tag('input', array('type'=>'submit', 'class'=>'btn btn-primary', 'value'=>$strcontinue)); + $html .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-primary', 'value' => $strcontinue)); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); diff --git a/mod/data/templates.php b/mod/data/templates.php index 704bfa5eadb..4d68d9fe127 100644 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -300,7 +300,8 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { echo ''; echo ''; - echo '



'; + echo '



'; + echo ''; echo '

'; if ($usehtmleditor) { $switchlink = new moodle_url($PAGE->url, ['useeditor' => false]); @@ -315,7 +316,8 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { ]); } } else { - echo '



'; + echo '



'; + echo ''; } echo ''; @@ -329,7 +331,10 @@ if ($mode == 'listtemplate'){ $field = 'template'; $editor->set_text($data->{$mode}); $editor->use_editor($field, $options); -echo '
'; +echo '
'; +echo ''; +echo '
'; echo ''; echo ''; @@ -342,19 +347,27 @@ if ($mode == 'listtemplate'){ $field = 'listtemplatefooter'; $editor->set_text($data->listtemplatefooter); $editor->use_editor($field, $options); - echo '
'; + echo '
'; + echo ''; + echo '
'; echo ''; echo ''; } else if ($mode == 'rsstemplate') { echo ''; echo ' '; echo ''; - echo '
'; + echo '
'; + echo ''; + echo '
'; $field = 'rsstitletemplate'; $editor->set_text($data->rsstitletemplate); $editor->use_editor($field, $options); - echo '
'; + echo '
'; + echo ''; + echo '
'; echo ''; echo ''; } From 930ce60550cb2829150907279721cb13654422e1 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 10 Nov 2016 16:25:48 +0800 Subject: [PATCH 3/3] MDL-56725 mod_data: better field alignment Labels containing only accesshide text should have the accesshide class on the label, not the content so the label does not push the content down. --- mod/data/field/multimenu/field.class.php | 4 ++-- mod/data/field/textarea/field.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mod/data/field/multimenu/field.class.php b/mod/data/field/multimenu/field.class.php index 7ab1405a377..92590d6199e 100644 --- a/mod/data/field/multimenu/field.class.php +++ b/mod/data/field/multimenu/field.class.php @@ -52,8 +52,8 @@ class data_field_multimenu extends data_field_base { $str = '
'; $str .= ''; // hidden field - needed for empty selection - $str .= '